Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a TextView look like a Setting's PreferenceCategory Header

This should be something pretty easy to figure out, but I've just not been able to find the answer anywhere.

I am trying to make a regular TextView look very similar, to the Preference Category Headers presented on Settings for any app. Here's what I mean:

Preference Category Header

Now, I have tried a few things, but I seem not to get it right. For example, I tried setting this:

android:drawableBottom="?android:attr/dividerVertical"

to my TextView, but that seems not to do anything at all, and my TextView Still looks like this:

Image not looking correctly

I've also tried simply setting a drawable I made:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
    android:width="1dp"         
    android:color="@android:color/darker_gray"
    />
</shape>

But That didn't come up on my text either.

This is the TextView style for now:

 <style name="NewTaskHeaderText">
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:textColor">@android:color/holo_blue_dark</item>
    <item name="android:minHeight">48dp</item>
    <item name="android:gravity">center_vertical</item>
    <item name="android:padding">8dp</item>
</style>

<TextView
    android:id="@+id/textView4"
    style="@style/NewTaskHeaderText"
    android:drawableBottom="@android:attr/dividerVertical"
    android:text="@string/some_text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

Any ideas would be appreciated.

like image 478
daniel_c05 Avatar asked Mar 12 '13 18:03

daniel_c05


People also ask

How do I make a TextView look like a link?

This is the shortest solution: final CharSequence text = tv. getText(); final SpannableString spannableString = new SpannableString( text ); spannableString. setSpan(new URLSpan(""), 0, spannableString.

How do I Auto Resize TextView?

To use preset sizes to set up the autosizing of TextView in XML, use the android namespace and set the following attributes: Set the autoSizeText attribute to either none or uniform. none is a default value and uniform lets TextView scale uniformly on horizontal and vertical axes.

How do I make TextView vertical?

Implement vertical TextView by calling setRotation() We can call the method of TextView object to make it display in vertical. Java code, call setRotation() to display the TextView (verticalTextView) in vertical. remark: Have to modify AndroidManifest. xml to set android:minSdkVersion="11" or higher.


1 Answers

<TextView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:text="foo"
    style="?android:attr/listSeparatorTextViewStyle" />

To do even more, look at this other SO answer

like image 121
Jon Avatar answered Nov 15 '22 16:11

Jon