У меня есть следующий XML-файл для макета панели навигации:
navigation_bar.xml
РЕДАКТИРОВАТЬ: Я упростил этот макет, удалив таблицураскладка.но sill ....
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/NavigationBar" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:src="@drawable/htc" />
<TextView
android:id="@+id/dummy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<Button
android:id="@+id/btn_home"
style="@style/NavigationButton"
android:layout_marginRight="10dp"
android:drawableTop="@drawable/btn_home"
android:text="" />
</LinearLayout>
и мой styles.xml файл:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NavigationBar">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">45dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/top</item>
<item name="android:dither">true</item>
</style>
<style name="NavigationButton">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:drawablePadding">2dp</item>
<item name="android:background">@null</item>
</style>
</resources>
Кроме того, кнопка для рисования: btn_home.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/home_pressed"
android:state_focused="true"
android:state_pressed="true" />
<item android:drawable="@drawable/home_pressed"
android:state_focused="false"
android:state_pressed="true" />
<item android:drawable="@drawable/home_selected" android:state_focused="true" />
<item android:drawable="@drawable/home_default"
android:state_focused="false"
android:state_pressed="false" />
</selector>
И я получаю следующий результат:
![Screenshot of result](https://i.stack.imgur.com/j88rW.png)
Смотрите, кнопка home отображается сверху.Но я хочу, чтобы он был в центре по вертикали.Для этого я указал <item name="android:layout_gravity">center_vertical</item>
в файле styles.xml
.Я пробовал android:layout_gravity="center_vertical|left"
также на navigation_bar.xml
.Но нет результата.Как я могу получить домашнюю фотографию в центр?Любая помощь приветствуется!