由网友(过往)分享简介:我有按钮,看起来像在横向上的图像:我希望它看起来像底部的形象。下面是我的.xml code这些按钮。<的TableRow机器人:ID =@ + ID / tableRow7机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:layout...![微信公众平台的视频怎么删除](https://p.xsw88.cn/allimgs/daicuo/20230907/4638.png)
我有按钮,看起来像在横向上的图像:
我希望它看起来像底部的形象。
下面是我的.xml code这些按钮。
<的TableRow
机器人:ID =@ + ID / tableRow7
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:weightSum =1.0>
<的ImageButton
机器人:ID =@ + ID / APPHOME
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =5
机器人:背景=@空
机器人:contentDescription =家
机器人:cropToPadding =真
机器人:scaleType =fitEnd
机器人:SRC =@可绘制/ home_bar/>
<的ImageButton
机器人:ID =@ + ID / menuHome
机器人:layout_weight =0
机器人:背景=@空
机器人:contentDescription =菜单
机器人:cropToPadding =真
机器人:scaleType =中心
机器人:SRC =@可绘制/ MENU_BAR/>
<的ImageButton
机器人:ID =@ + ID /后退
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =5
机器人:背景=@空
机器人:contentDescription =后退
机器人:cropToPadding =真
机器人:scaleType =fitStart
机器人:SRC =@可绘制/ back_bar/>
< /的TableRow>
解决方案
我最终通过切换我TableLayout到的LinearLayout解决这个。这是我的code,除非其他人遇到这个问题:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =center_horizontal
机器人:方向=垂直>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:重力=中心>
<的ImageButton
机器人:ID =@ + ID / APPHOME
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@空
机器人:contentDescription =家
机器人:scaleType =fitEnd
机器人:SRC =@可绘制/ home_bar_grey/>
<的ImageButton
机器人:ID =@ + ID / menuHome
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@空
机器人:contentDescription =菜单
机器人:的onClick =menuhome
机器人:scaleType =fitCenter
机器人:SRC =@可绘制/ MENU_BAR/>
<的ImageButton
机器人:ID =@ + ID /后退
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@空
机器人:contentDescription =后退
机器人:scaleType =fitStart
机器人:SRC =@可绘制/ exit_bar/>
< / LinearLayout中>
![微信公众平台的视频怎么删除](https://p.xsw88.cn/allimgs/daicuo/20230907/4638.png)
I have Buttons that look like the top image for the landscape orientation:
I want it to look like the bottom image.
Here's my .xml code for these buttons.
<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:weightSum="1.0" >
<ImageButton
android:id="@+id/appHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:background="@null"
android:contentDescription="Home"
android:cropToPadding="true"
android:scaleType="fitEnd"
android:src="@drawable/home_bar" />
<ImageButton
android:id="@+id/menuHome"
android:layout_weight="0"
android:background="@null"
android:contentDescription="Menu"
android:cropToPadding="true"
android:scaleType="center"
android:src="@drawable/menu_bar" />
<ImageButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:background="@null"
android:contentDescription="Back"
android:cropToPadding="true"
android:scaleType="fitStart"
android:src="@drawable/back_bar" />
</TableRow>
解决方案
I ended up fixing this by switching my TableLayout to a LinearLayout. Here's my code unless anyone else comes across this problem:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<ImageButton
android:id="@+id/appHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="Home"
android:scaleType="fitEnd"
android:src="@drawable/home_bar_grey" />
<ImageButton
android:id="@+id/menuHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="Menu"
android:onClick="menuhome"
android:scaleType="fitCenter"
android:src="@drawable/menu_bar" />
<ImageButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="Back"
android:scaleType="fitStart"
android:src="@drawable/exit_bar" />
</LinearLayout>
相关推荐
最新文章