【问题标题】:Wrap a layout in a border将布局包裹在边框中
【发布时间】:2011-04-28 14:54:26
【问题描述】:

我正在尝试创建一个围绕多个文本框的边框。我已经能够通过在 XML 中定义一个形状然后使用该形状作为我的背景来做到这一点。这是定义的形状。

<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <stroke android:width="1dp" android:color="#787878" /> 
  <padding android:left="7dp" android:top="7dp" 
           android:right="7dp" android:bottom="7dp" /> 
  <corners android:radius="4dp" />  
</shape>

这是我使用它的方式。目前只是在文本视图上。

<TextView 
  android:background="@drawable/my_border"
    android:id="@+id/item_text"
    android:layout_margin="5dip"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:layout_centerHorizontal="true"
    android:text="@string/item_text"
    android:textColor="#787878"
    android:layout_width="wrap_content"
    android:textStyle="bold"/>

这实际上按预期绘制了边框,但板内的颜色,即 textview 的背景是黑色的。我不知道为什么会这样。任何有助于将我推向正确方向的猜测表示赞赏。

谢谢

【问题讨论】:

    标签: android xml android-layout


    【解决方案1】:

    尝试将&lt;solid android:color="#ffffff" /&gt; 添加到您的shape 定义中。

    【讨论】:

      猜你喜欢
      • 2013-08-16
      • 1970-01-01
      • 2011-08-05
      • 1970-01-01
      • 2021-03-02
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2017-05-12
      相关资源
      最近更新 更多