Android selector & text color

I got by doing several tests until one worked, so: res/color/button_dark_text.xml <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”true” android:color=”#000000″ /> <!– pressed –> <item android:state_focused=”true” android:color=”#000000″ /> <!– focused –> <item android:color=”#FFFFFF” /> <!– default –> </selector> res/layout/view.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”EXIT” android:textColor=”@color/button_dark_text” /> </LinearLayout>

How to click or tap on a TextView text

You can set the click handler in xml with these attribute: android:onClick=”onClick” android:clickable=”true” Don’t forget the clickable attribute, without it, the click handler isn’t called. main.xml … <TextView android:id=”@+id/click” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Click Me” android:textSize=”55sp” android:onClick=”onClick” android:clickable=”true”/> … MyActivity.java public class MyActivity extends Activity { public void onClick(View v) { … } }

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

TextView comes with 4 compound drawables, one for each of left, top, right and bottom. In your case, you do not need the LinearLayout and ImageView at all. Just add android:drawableLeft=”@drawable/up_count_big” to your TextView. See TextView#setCompoundDrawablesWithIntrinsicBounds for more info.

Shadow Effect for a Text in Android?

put these in values/colors.xml <resources> <color name=”light_font”>#FBFBFB</color> <color name=”grey_font”>#ff9e9e9e</color> <color name=”text_shadow”>#7F000000</color> <color name=”text_shadow_white”>#FFFFFF</color> </resources> Then in your layout xml here are some example TextView’s Example of Floating text on Light with Dark shadow <TextView android:id=”@+id/txt_example1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textSize=”14sp” android:textStyle=”bold” android:textColor=”@color/light_font” android:shadowColor=”@color/text_shadow” android:shadowDx=”1″ android:shadowDy=”1″ android:shadowRadius=”2″ /> Example of Etched text on Light with Dark shadow <TextView … Read more

Rounded corner for textview in android

Create rounded_corner.xml in the drawable folder and add the following content, <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <stroke android:width=”1dp” android:color=”@color/common_border_color” /> <solid android:color=”#ffffff” /> <padding android:left=”1dp” android:right=”1dp” android:bottom=”1dp” android:top=”1dp” /> <corners android:radius=”5dp” /> </shape> Set this drawable in the TextView background property like so: android:background=”@drawable/rounded_corner” I hope this is useful for you.