###前提・実現
Android にて、下タブを実装したく、
画像を9-patchで作ったのですが、うまく狙い通りに定まってくれません。
タブは4つの選択肢があり、そのアイコンが、各種、中央にぴったり収まって欲しいのですが、
横に伸びてしまいます。どのように解決すればよいでしょうか?
###該当のソースコード
xml
1<!--activity_main.xml--> 2<?xml version="1.0" encoding="utf-8"?> 3<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:paddingBottom="@dimen/activity_vertical_margin" 8 android:paddingLeft="@dimen/activity_horizontal_margin" 9 android:paddingRight="@dimen/activity_horizontal_margin" 10 android:paddingTop="@dimen/activity_vertical_margin" 11 tools:context="com.example.teiyuueki.reginaactionbarbottmtab1.MainActivity"> 12 13 <TextView 14 android:layout_width="wrap_content" 15 android:layout_height="wrap_content" 16 android:text="Hello World!" /> 17 18 <!-- 下メニュー --> 19 <LinearLayout 20 android:id="@+id/footerlayout2" 21 android:layout_width="match_parent" 22 android:layout_height="48dp" 23 android:layout_alignParentBottom="true" 24 > 25 26 <RadioGroup 27 android:id="@+id/radioGroup2" 28 android:layout_width="match_parent" 29 android:layout_height="52dp" 30 android:orientation="horizontal" > 31 32 <RadioButton 33 android:id="@+id/radio_conclusion" 34 android:layout_width="0dp" 35 android:layout_height="match_parent" 36 android:layout_weight="1" 37 android:background="@layout/selector_tab_bar" 38 android:button="@null" 39 android:checked="true" /> 40 41 <RadioButton 42 android:id="@+id/radio_bar" 43 android:layout_width="0dp" 44 android:layout_height="match_parent" 45 android:layout_weight="1" 46 android:background="@layout/selector_tab_bar" 47 android:button="@null" /> 48 49 50 <RadioButton 51 android:id="@+id/radio_chart" 52 android:layout_width="0dp" 53 android:layout_height="match_parent" 54 android:layout_weight="1" 55 android:background="@layout/selector_tab_bar" 56 android:button="@null" /> 57 <RadioButton 58 android:id="@+id/radio_mypage" 59 android:layout_width="0dp" 60 android:layout_height="match_parent" 61 android:layout_weight="1" 62 android:background="@layout/selector_tab_bar" 63 android:button="@null" /> 64 </RadioGroup> 65 </LinearLayout> 66</RelativeLayout> 67
xml
1<!--selector_tab_bar.xml--> 2<?xml version="1.0" encoding="utf-8"?> 3<selector xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_height="wrap_content" 5 android:layout_width="wrap_content"> 6 <!-- 選択時 --> 7 <item android:state_checked="true" 8 android:drawable="@drawable/growing_active"> 9 </item> 10 <!-- 非選択時 --> 11 <item android:drawable="@drawable/tabbar_button_home"> 12 </item> 13</selector>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。