如何移除LinearLayout中烦人的1像素透明边框?

3
你是否注意到,实际上android LinearLayout有1像素的透明边框?我有一个嵌套在另一个RelativeLayout中的LinearLayout。LinearLayout与其父布局底部对齐。然而,我仍然可以在LinearLayout下方得到1像素的透明边框。以下是图片。 1px transparent border under LinearLayout 如何删除边框?以下是我的代码。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/gray"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
  android:id="@+id/llFooter"
  android:layout_alignParentBottom="true"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  style="@style/st_record_bar">
  <ToggleButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:background="@drawable/btn_record_big_selector"
     android:textOn=""
     android:textOff="" />
</LinearLayout>
</RelativeLayout>

@style/st_record_bar被定义为

<style name="st_record_bar">
  <item name="android:gravity">center_vertical|center_horizontal|center</item>
  <item name="android:padding">15dip</item>
  <item name="android:background">@drawable/bg_record_bar</item>
</style>

@PolamReddyRajaReddy 这里是代码。它只是普通的RelativeLayout和LinearLayout嵌套。 - jcadam
1
为什么你在使用 style="@style/st_record_bar",我认为你是想得到边框效果,尝试移除它然后再检查一下。 - RajaReddy PolamReddy
粘贴了样式定义。尝试删除样式属性,但没有成功。我认为样式定义中没有任何错误导致这种情况。 - jcadam
由于某些原因,当我使用按钮时发生了这种情况。如果可以的话,请尝试用TextView替换ToggleButton。 - Patrick
1个回答

1

改成这样

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:background="@color/gray"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
<LinearLayout
   android:id="@+id/llFooter"
   android:layout_alignParentBottom="true"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">
<ToggleButton
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"

   android:textOn=""
   android:textOff="" />
  </LinearLayout>
</RelativeLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接