标签:android android-layout imagebutton tablelayout
我有2个像这样的ImageButons
我已经尝试了一切,使其在屏幕中心正确对齐.作为Android新手,我没有任何其他线索可以做什么.如何实现我在屏幕中心对齐这两个图像按钮的目标
这是我的布局xml
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton android:id="@+id/btn_Show"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Show" android:src="@drawable/cmd_result_show"
android:layout_gravity="right" android:background="@android:color/transparent" />
<ImageButton android:id="@+id/btn_showAll"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Detailed Show" android:layout_gravity="center"
android:src="@drawable/cmd_result_details" android:background="@android:color/transparent" />
</TableRow>
</TableLayout>
解决方法:
我希望你直接拥有这些按钮的图像.所以这个设置文本属性是没用的.使用RelativeLayout可以轻松开发这类屏幕.
下面我附上了代码.如果有任何问题,请查看并添加评论.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center_horizontal">
<ImageButton android:id="@+id/btn_Show"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/cmd_result_show" />
<ImageButton android:id="@+id/btn_showAll"
android:layout_toRightOf="@id/btn_Show" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/cmd_result_details" />
</RelativeLayout>
标签:android,android-layout,imagebutton,tablelayout 来源: https://codeday.me/bug/20190518/1128574.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。