-
-
Save udacityandroid/e11b81e3bdcff1c073c6e24a4fdb3365 to your computer and use it in GitHub Desktop.
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="@color/tan_background" | |
| android:orientation="vertical" | |
| tools:context="com.example.android.miwok.MainActivity"> | |
| <!-- Numbers category --> | |
| <FrameLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@color/category_numbers"> | |
| <TextView | |
| android:id="@+id/numbers" | |
| style="@style/CategoryStyle" | |
| android:background="?android:attr/selectableItemBackground" | |
| android:text="@string/category_numbers" /> | |
| </FrameLayout> | |
| <!-- Family category --> | |
| <FrameLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@color/category_family"> | |
| <TextView | |
| android:id="@+id/family" | |
| style="@style/CategoryStyle" | |
| android:background="?android:attr/selectableItemBackground" | |
| android:text="@string/category_family" /> | |
| </FrameLayout> | |
| <!-- Colors category --> | |
| <FrameLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@color/category_colors"> | |
| <TextView | |
| android:id="@+id/colors" | |
| style="@style/CategoryStyle" | |
| android:background="?android:attr/selectableItemBackground" | |
| android:text="@string/category_colors" /> | |
| </FrameLayout> | |
| <!-- Phrases category --> | |
| <FrameLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@color/category_phrases"> | |
| <TextView | |
| android:id="@+id/phrases" | |
| style="@style/CategoryStyle" | |
| android:background="?android:attr/selectableItemBackground" | |
| android:text="@string/category_phrases" /> | |
| </FrameLayout> | |
| </LinearLayout> |
It works fine for me, could you print your code here, so we can see what it looks like?
Regards,
showing error
@saugatrai33
Well you don't need to add it to style.xml. Just copy and paste it to your already defined activity_main.xml. It will work.
Work fine for me.
Thanks
all words disappeared!!
beautiful details
Hi @saugatrai33, ripple.xml must be created in the @drawable folder.
Here is an example with background style. Enjoy it
ripple.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/black" >
<item android:drawable="@drawable/background">
</item>
</ripple>background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/darker_gray" />
</shape>thanks
all words disappeared!!
Go to styles.xml and in the Style Tag named "CategoryStyle" use:
<item name="android:layout_height">wrap_content</item>
in place of:
<item name="android:layout_height">0dp</item>
March 2021 Still looks great, thank you.
July 2021 Still looks great, thank you.
From API Level 22 onwards just add this property to xml layout : android:foreground="?attr/selectableItemBackground" and it will work smoothly add the background color accordingly.
it is the same issue for me, no working