现在的状态:
1.我做了一个selector用来定义按钮显示的状态
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_left_e" />
<item android:state_enabled="true" android:drawable="@drawable/btn_left_n" />
<item android:state_pressed="false" android:drawable="@drawable/btn_left_n" />
<item android:state_pressed="true" android:drawable="@drawable/btn_left_e" />
<item android:state_focused="true" android:drawable="@drawable/btn_left_e" /> <item android:drawable="@drawable/btn_left_n" />
</selector>2.我做了一个LinearLayout里面放了两个按钮
<LinearLayout android:orientation="horizontal" android:gravity="center_vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:gravity="left" android:id="@+id/preQuestion" android:layout_weight="1"
android:background="@drawable/btn_left" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:scaleType="center" /> <Button android:gravity="left" android:id="@+id/nextQuestion"
android:layout_toRightOf="@+id/preQuestion" android:layout_weight="1"
android:background="@drawable/btn_right" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:scaleType="center" />
</LinearLayout>现象:
两个按钮被拉伸了,充满了整个LinearLayout,这是我想要的状态。问题:
按钮上的图片同样被拉伸着充满了整个的按钮。
能不能图片不被拉伸,只显示在按钮中间,但按钮的区域被拉伸了?
1.我做了一个selector用来定义按钮显示的状态
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/btn_left_e" />
<item android:state_enabled="true" android:drawable="@drawable/btn_left_n" />
<item android:state_pressed="false" android:drawable="@drawable/btn_left_n" />
<item android:state_pressed="true" android:drawable="@drawable/btn_left_e" />
<item android:state_focused="true" android:drawable="@drawable/btn_left_e" /> <item android:drawable="@drawable/btn_left_n" />
</selector>2.我做了一个LinearLayout里面放了两个按钮
<LinearLayout android:orientation="horizontal" android:gravity="center_vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:gravity="left" android:id="@+id/preQuestion" android:layout_weight="1"
android:background="@drawable/btn_left" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:scaleType="center" /> <Button android:gravity="left" android:id="@+id/nextQuestion"
android:layout_toRightOf="@+id/preQuestion" android:layout_weight="1"
android:background="@drawable/btn_right" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:scaleType="center" />
</LinearLayout>现象:
两个按钮被拉伸了,充满了整个LinearLayout,这是我想要的状态。问题:
按钮上的图片同样被拉伸着充满了整个的按钮。
能不能图片不被拉伸,只显示在按钮中间,但按钮的区域被拉伸了?
解决方案 »
- 请问如何实时获取剪贴板改变的消息
- 安卓 EditText 取值问题
- The content of the adapter has changed but....
- 请教下android 如何获取下载信息
- 请问有谁做过拍照上传功能吗,就是象微博那样,可以从sd卡得到照片或拍新照片
- android intent和service的显示和隐示具体是什么意思????
- 适配器里的getItem和getItemId作用是什么??
- Android通讯录
- Android studio从2.3更新到3.1后,logcat工具显示的就有问题,实在影响分析log,有没有解决的办法啊?
- 每次startService都是一个AIDL过程吗?
- 听说这里的Android高手较多,故此高分悬赏解答
- listview取值问题
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/btn_left_e" android:gravity="center_vertical"
android:tileMode="clamp" />
建议楼主用ImageButton吧 图片控制显示区域比较好控制的
如果实在不行,就重写相应的控件,然后添加一个方法,在onDraw()函数中绘制,不要拉伸就行了。