[英]Issue with ScrollView when applying padding or layout_margin
在我的xml布局文件中,我有一个ScrollView
。 在使用权重在每个TableRow中分离TextView之前,但这不能满足我的需要,因此我决定在TableLayout
使用列。
我的问题出在我尝试将填充应用于ScrollView或“ Container” RelativeLayout时,某些文本被截断了。 如果我适用于ScrollView的任何子级,则它不会显示TableLayout的最底部。 当我将填充仅应用于TableLayout中的TableRows时,与我想要的最接近的是,但是“生成版本”文本被水平切断(请参见下面的屏幕截图)。 除此之外,这将是令人满意的。
layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="@+id/svMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adMainBanner"
android:layout_alignParentTop="true"
android:fillViewport="true" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- Build -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:gravity="center_horizontal"
android:text="@string/build"
android:textSize="18sp"
android:textStyle="bold" />
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/manufacturer" />
<TextView
android:id="@+id/tvManufacturer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/model" />
<TextView
android:id="@+id/tvModel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/hardware" />
<TextView
android:id="@+id/tvHardware"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/board" />
<TextView
android:id="@+id/tvBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/bootloader" />
<TextView
android:id="@+id/tvBootLoader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/device" />
<TextView
android:id="@+id/tvDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/brand" />
<TextView
android:id="@+id/tvBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/android_version" />
<TextView
android:id="@+id/tvAndroidVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/build_version" />
<TextView
android:id="@+id/tvBuildVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<!-- Service / Carrier -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="@string/carrier_service"
android:textSize="18sp"
android:textStyle="bold" />
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/carrier" />
<TextView
android:id="@+id/tvCarrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/phone_number" />
<TextView
android:id="@+id/tvPhoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/service_mode" />
<TextView
android:id="@+id/tvServiceMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<!-- Network -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="@string/network"
android:textSize="18sp"
android:textStyle="bold" />
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/phone_type" />
<TextView
android:id="@+id/tvPhoneType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/network_type" />
<TextView
android:id="@+id/tvNetworkType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<TableRow android:layout_width="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="@string/baseband" />
<TextView
android:id="@+id/tvBaseBand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="text" />
</TableRow>
<!-- CPU -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="@string/cpu_info"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvCpuInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="text" />
<!-- Ram -->
<!-- If I apply padding/margin to any container layout,
this gets cut off(does not show in scrollview)-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="@string/ram_info"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvRamInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:text="text" />
</TableLayout>
</ScrollView>
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adMainBanner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="@string/admob_banner_id"
googleads:loadAdOnCreate="true" />
</RelativeLayout>
游戏内截图
没有任何填充或边距的外观,生成版本被截断:
这是整个构建版本:
为什么“构建版本”文本不换行? 在达到上述要求之后,应该如何在我的整个布局文件中应用填充/边距而又不使ScrollView内的内容枯燥? 请任何帮助,不胜感激:)
可能是因为它不包含任何空格。 尝试:
android:singleLine="false"
要么
android:ems="30" // or whatever number of characters you want per line
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.