【发布时间】:2011-08-29 16:27:41
【问题描述】:
所以我有这个问题。我制作了一个按钮和一个 .xml 按钮选择器文件,除了一件事,一切都很好。
我想要发生的事情:当您单击(或选择)按钮时,按钮会变小(准确地说,它会变为较小的 .png 文件)。
发生了什么:当您单击(或选择)按钮时,按钮并没有变小,而是被拉长以适合父级(总而言之,大小保持不变)。我认为这与错误的布局参数有关。你能帮帮我吗?这是一些代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/listbg"
android:paddingTop="110dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ScrollView
android:id="@+id/scrollView1"
android:layout_height="fill_parent"
android:layout_width="wrap_content">
<RelativeLayout
android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal">
<Button android:layout_height="wrap_content"
android:id="@+id/Button1"
android:background="@drawable/placestovisit"
android:state_pressed="true"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"/>
<!-- This is the button I am talking about -->
<Button android:layout_height="wrap_content"
android:id="@+id/Button2"
android:background="@drawable/mostpopular_button"
android:layout_width="wrap_content"
android:layout_below="@+id/Button1"/>
【问题讨论】:
标签: android button size selector