【发布时间】:2015-03-13 22:15:17
【问题描述】:
我有一个问题,我的三星 Galaxy S5 上的 Android 应用程序 UI 与 Nexus5 或 Sony Xperia 等其他设备相比看起来不同..
我有排列在 TableLayout 内的 TextView。 每个 TextView 都有一个带有小笔画可绘制背景的矩形,它在单独的 xml 中定义。
问题是您可以看到矩形左侧的笔划,但右侧似乎被隐藏起来,就像它比屏幕宽一样。 我尝试加载图片,但我没有足够的声誉。
正如我所说,它只发生在我的三星设备上,而在其他设备上看起来还不错。
请参考布局xml和背景可绘制xml。
谁能解释一下为什么会这样,也许可以提出解决方案?
这是布局xml的:
<RelativeLayout 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:orientation="vertical"
tools:context=".GpsRecMain"
android:background="@color/LightGrey">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:stretchColumns="*.*" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tvTimer"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/black_text_box"
android:gravity="center"
android:text="00:00"
android:textColor="@color/YellowGreen"
android:textSize="35sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tvSpeed"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/black_text_box"
android:gravity="center"
android:text="@string/NUMERIC_ZERO"
android:textColor="@color/YellowGreen"
android:textSize="40sp"
android:textStyle="bold|italic" />
<TextView
android:id="@+id/tvDistance"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/black_text_box"
android:gravity="center"
android:text="@string/NUMERIC_ZERO"
android:textColor="@color/YellowGreen"
android:textSize="40sp"
android:textStyle="bold|italic" />
</TableRow>
</TableLayout>
背景xml:
<?xml version="1.0" encoding="utf-8"?>
<corners android:radius="0dp" />
<solid android:color="@color/Black"/>
<stroke android:width="3px"
android:color="@color/YellowGreen"/>
<padding android:top="5dp"
android:bottom="5dp"/>
提前致谢! 莫蒂。
【问题讨论】:
-
“我尝试加载图片,但我没有足够的声誉”——然后将屏幕截图上传到其他地方并从此处链接到它们。
-
最顶层的RelativeLayout改成android:layout_width="match_parent"怎么样?
-
我尝试更改布局属性,如“match_parent”,但没有任何帮助。我会尝试加载图片并链接到它。
-
大家好,这是它在我的 S5 上的样子:drive.google.com/file/d/0B_u6KEV21eGGdG5KREtmcWtESnM/… 您可以看到右侧看起来比屏幕宽,而左侧则完美..
标签: android xml android-layout