Android,水平拉伸三幅图像在7英寸的设备上不起作用
我下面的代码在小屏幕设备(如3.7、4和4.6设备)上正常工作。这是页脚菜单,在按钮屏幕上包含三个图像 当我在7台设备上启动应用程序时,所有这三张图片都对齐。但这些图片并没有拉伸到填满屏幕。它们只填满了屏幕的一半,其余的什么都没有 如有任何意见,将不胜感激。谢谢Android,水平拉伸三幅图像在7英寸的设备上不起作用,android,android-layout,Android,Android Layout,我下面的代码在小屏幕设备(如3.7、4和4.6设备)上正常工作。这是页脚菜单,在按钮屏幕上包含三个图像 当我在7台设备上启动应用程序时,所有这三张图片都对齐。但这些图片并没有拉伸到填满屏幕。它们只填满了屏幕的一半,其余的什么都没有 如有任何意见,将不胜感激。谢谢 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
android:id="@+id/footerBarContainer" >
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbBrowse"
android:background="@drawable/btn_tg_browse"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"
android:gravity="bottom"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbHotSpot"
android:background="@drawable/btn_tg_hotspot"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="true"
android:gravity="bottom"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbMatches"
android:background="@drawable/btn_tg_matches"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"
android:gravity="bottom"/>
</LinearLayout>
最后,我找到了解决方案。我确信上面的代码我在问题中写的代码是正确的。但是我不知道为什么我的G标签8显示得不好 我在页脚顶部添加了新的透明视图。虽然这不是一种干净的方式,但至少在我的平板电脑上有效。这是新代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/transparent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/footerBarContainer">
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbBrowse"
android:background="@drawable/btn_tg_browse"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbHotSpot"
android:background="@drawable/btn_tg_hotspot"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="true"/>
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tbMatches"
android:background="@drawable/btn_tg_matches"
android:textOn=""
android:textOff=""
android:focusable="false"
android:focusableInTouchMode="false"
android:checked="false"/>
</LinearLayout>
</LinearLayout>
我的平板电脑上的屏幕截图:
嗯,真的很奇怪。投票吧,当你解决这个问题时,我想知道问题出在哪里。我会说你在layout-sw600dp中有不同的布局,但我不认为你犯了那种错误:谢谢koso,这对我来说也很奇怪。不,我没有那个文件夹,因为我的要求只是手机。但是当我把它安装到我的手机上时ab 8.0,页脚就是这样。我确信我的代码是正确的,因为在Intellij Idea的设计视图中,它显示页脚在7和10台设备上正确拉伸。只是在真实设备上它不会拉伸!!!这可能是特定于设备的问题,也可能是特定于android版本的问题。你在不同的平板电脑上尝试过吗?也许我会尝试从按钮保持架上删除weightSumR.你能展示整个XML,或者至少是保存这个条的一个吗?同时,请考虑阅读谷歌的指导方针,因为这不是谷歌建议显示标签的方式。这里有一个示例链接:不遵循设计指南的应用程序在玩商店的时候有更少的机会出现。@ KOSO我找到了一个解决方案。请检查一下。k it。由于使用背景,它会被拉伸。您可能希望从ImageView进行扩展,以保持图像的纵横比: