Nasıl v7 appcompat kütüphane 21 Android gelen DrawerArrowToggle uygulamak
Şimdi Android 5.0 yayınlandı çok hareketli actionbar simgeler nasıl uygulanacağı merak ediyordum.
Bu kütüphane here appcompat v7 kütüphanenin sahip olduğu için benim için gayet iyi ama uygulayan ne kadar uygulanabilir?
Kütüphane themes.xml bu başvurular
<item name="drawerArrowStyle">@style/Widget.AppCompat.DrawerArrowToggle</item>
Bu stil altında
<style name="Base.V7.Theme.AppCompat" parent="Platform.AppCompat">
GÜNCELLEME
Bu v7 DrawerToggle kullanarak uygulanan aldım. Ancak tarzı olamaz. Yardım Lütfen
V7 styles_base.xml bunu için stil buldum
<style name="Base.Widget.AppCompat.DrawerArrowToggle" parent="">
<item name="color">?android:attr/textColorSecondary</item>
<item name="thickness">2dp</item>
<item name="barSize">18dp</item>
<item name="gapBetweenBars">3dp</item>
<item name="topBottomBarArrowSize">11.31dp</item>
<item name="middleBarArrowSize">16dp</item>
<item name="drawableSize">24dp</item>
<item name="spinBars">true</item>
</style>
Benim için bu stiller ekledim ve çalışmadı. Ayrıca benim attr.xml eklendi
<declare-styleable name="DrawerArrowToggle">
<!-- The drawing color for the bars -->
<attr name="color" format="color"/>
<!-- Whether bars should rotate or not during transition -->
<attr name="spinBars" format="boolean"/>
<!-- The total size of the drawable -->
<attr name="drawableSize" format="dimension"/>
<!-- The max gap between the bars when they are parallel to each other -->
<attr name="gapBetweenBars" format="dimension"/>
<!-- The size of the top and bottom bars when they merge to the middle bar to form an arrow -->
<attr name="topBottomBarArrowSize" format="dimension"/>
<!-- The size of the middle bar when top and bottom bars merge into middle bar to form an arrow -->
<attr name="middleBarArrowSize" format="dimension"/>
<!-- The size of the bars when they are parallel to each other -->
<attr name="barSize" format="dimension"/>
<!-- The thickness (stroke size) for the bar paint -->
<attr name="thickness" format="dimension"/>
</declare-styleable>
Ama çöker ve bunu yaparken diyor renk tipi hata. Neyi kaçırıyorum?
CEVAP
İlk, şimdi android.support.v4.app.ActionBarDrawerToggle
önerilmiyor bilmelisin.
android.support.v7.app.ActionBarDrawerToggle
ile değiştirmeniz gerekir.
Burada benim örnek ve ActionBar
değiştirmek için Toolbar
yeni kullanıyorum.
MainActivity.java
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(
this, mDrawerLayout, mToolbar,
R.string.navigation_drawer_open, R.string.navigation_drawer_close
);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle.syncState();
}
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
AndroidDocument#DrawerArrowToggle_spinBars belgeleri okuyabilirsiniz
Bu öznitelik menü-ok animasyon uygulamak için anahtardır.
public static int DrawerArrowToggle_spinBars
İster Bar Geçiş sırasında ya da değil dönmelidir
Bir boolean değeri, ya da olması gerekir "" veya"". false true
Yani, bu ayarlayın: <item name="spinBars">true</item>
.
Sonra animasyon sunulabilir.
Bu umut size yardımcı olabilir.
Nasıl Eclipse içinde bir kütüphane (an...
Nasıl Android Studio için kütüphane pr...
Nasıl Pull-to-Yenileme Android uygulam...
Nasıl Android bir PreferenceActivity g...
Nasıl gelen kutusuna gelen mesajları P...