【问题标题】:android textView style with vertical line on the left左侧带有垂直线的android textView样式
【发布时间】:2014-04-08 02:31:45
【问题描述】:

有什么方法可以为我的 TextView [不使用其他小部件] 赋予样式,例如下面屏幕截图中的 NOTE 样式? [左边的一条垂直线]

【问题讨论】:

    标签: android styles textview


    【解决方案1】:

    你能做类似以下的事情吗?

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="5dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:orientation="vertical" >
            </LinearLayout>
    
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/linearLayout1"
                android:text="TextView" />
        </RelativeLayout>
    

    【讨论】:

    • 谢谢,这可行,但我真的不想使用它,因为 textview 的可见性在运行时变化很大,所以很麻烦,所以我不想使用任何小部件
    【解决方案2】:

    通过使用 android:drawableLeft for textview 尝试在 textview 左侧使用您想要的任何图像

    <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/button_icon" />
    

    【讨论】:

    • 谢谢,这是我一直在寻找的……但是可以根据 textview 中的文本动态调整可绘制对象的高度吗?
    • 为可绘制对象创建一个 9-patch 图像是我的建议。然后,高度会自行调整
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    • 2013-01-04
    • 2011-12-18
    • 1970-01-01
    • 2012-05-23
    相关资源
    最近更新 更多