jbe*_*itz 5 xml layout android
我目前正在设计一个带有5个按钮的ButtonBar(它们都是ImageButtons,但目前只有3个).这是我的第一个android项目,所以我正在学习.我试图平均加权每个按钮,而不缩放它们(具有相等的填充而不是相等的宽度).到目前为止这是我的代码:
<LinearLayout
android:id="@+id/back"
android:orientation="horizontal"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
style="@android:style/ButtonBar"
android:weightSum="5"
>
<ImageButton
android:id="@+id/info_button"
android:padding="20dp"
android:background="@drawable/info"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
<Button
android:id="@+id/wishlist_button"
android:text="@string/wish_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"></Button>
<Button
android:id="@+id/buy_button"
android:text="@string/buy_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:textSize="15dip"
android:textColor="#b7b7b7"/>
<ImageButton
android:id="@+id/dislike_button"
android:padding="20dp"
android:background="@drawable/dislike_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
<ImageButton
android:id="@+id/like_button"
android:padding="20dp"
android:background="@drawable/like_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
/>
Run Code Online (Sandbox Code Playgroud)
这就是它现在的样子:拉伸加权:http://i.imgur.com/MAfjp.png
这就是我希望它看起来像(紧密):非拉伸同样填充:http://i.imgur.com/vXTEy.png
谢谢你的帮忙.我一直在寻找答案,并且已经尝试了很多.
这里是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/back"
android:orientation="horizontal"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:background="#000000"
style="@android:style/ButtonBar"
android:gravity="center"
>
<ImageButton
android:id="@+id/info_button"
android:background="@null"
android:src="@drawable/info"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/wishlist_button"
android:text="@string/wish_label"
android:background="@null"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:textSize="15dip"
android:textColor="#b7b7b7"></Button>
<Button
android:id="@+id/buy_button"
android:text="@string/buy_label"
android:background="@null"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:textSize="15dip"
android:textColor="#b7b7b7"/>
<ImageButton
android:id="@+id/dislike_button"
android:background="@null"
android:src="@drawable/dislike_button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
<ImageButton
android:id="@+id/like_button"
android:background="@null"
android:src="@drawable/like_button"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我不知道如何设置style ="@ android:style/ButtonBar",所以如果它没有正确显示,请尝试删除它.
| 归档时间: |
|
| 查看次数: |
5055 次 |
| 最近记录: |