【问题标题】:How can I get text to show up in my rectangle, but I can't even get the rectangle to show?如何让文本显示在我的矩形中,但我什至无法显示矩形?
【发布时间】:2014-03-03 20:37:17
【问题描述】:

我正在尝试让此代码适用于我的 Android 应用,但我无法显示我的矩形,而且我不知道如何将文本放入此矩形。

这是我的 shape.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <stroke android:width="1dp"
        android:color="#ababab"
    />

    <padding android:left="1dp"
         android:top="1dp"
         android:right="1dp"
         android:bottom="1dp"
     /> 

    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="7dp" android:topRightRadius="7dp"/>  
</shape>

这是我的 fragment_task.xml

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/shape"
        android:orientation="vertical"
        android:layout_marginRight="10dp"   
        android:id="@+id/linearLayout">

    </LinearLayout>

</GridLayout>

【问题讨论】:

标签: java android eclipse


【解决方案1】:

线性布局设置为包裹内容,内部没有任何内容。您可能想要做的是将文本视图放入线性布局中,因此只需移动它,或者只是删除线性布局并将 textview 背景设置为您的可绘制对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 2013-03-29
    • 1970-01-01
    相关资源
    最近更新 更多