Problems with the reverse compatibility of AppCompat, Android below 5



  • Dobra all! Added Annex App Bar to this instruction ActionBar и под ним закрытый Spinner Раскрытый Spinner Меню в ActionBar

    What is done:

    1 - In gradle, the library is connected to the module

    compile 'com.android.support:appcompat-v7:23.4.0'
    

    2 - Manifeste has an annex topic

    <application
        ...
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
    

    3 - The Toolbar and Spinner species are added to Layout to activate

    <android.support.v7.widget.Toolbar
        android:id="@+id/my_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
    

    <Spinner
    android:layout_height="wrap_content"
    android:id="@+id/userSpinner"
    app:layout_constraintTop_toBottomOf="@+id/my_toolbar"
    app:layout_constraintRight_toRightOf="@+id/my_toolbar"
    android:layout_width="match_parent" />

    4 - Activate itself from AppCompatActivity and add Toolbar and Spinner

    public class MainActivity extends AppCompatActivity {

    private String[] spinnerData = {"item 1", "item 2", "item 3", "item 4"};
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(myToolbar);
    
        //[START make spinner]
        final Spinner spinner = (Spinner) findViewById(R.id.userSpinner);
        ArrayAdapter&lt;String&gt; customAdapter = new ArrayAdapter&lt;&gt; (this, android.R.layout.simple_spinner_item, spinnerData);
        spinner.setAdapter(customAdapter);
        //[STOP make spinner]
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.action_bar_menu, menu);
        return true;
    }
    

    }

    I end up as good as pictures. How to fight?



  • See what you got. build.gradle Annex module compileSdkVersion not above 23, buildToolsVersion Not above 23.0.2, targetSdkVersion not above 23. Main build.gradle version not above "com.android.tools.build:gradle:2.1.2"♪ These are the last stable versions. If you put it above, you can expect any effects, including those. And the studio would be better equipped with a stable 2.1.2. Actually, if you're working with the unstable versions and what's going on, it's better to start with a check, as long as it's stable. Actually, you've got 9-patches for why you've stopped taking 9-patches and looking like pictures. Whether the collection system is gluing or whether the resources themselves came from somewhere. ♪ ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2