android - Include parent padding in selected state of TextView -
i have relativelayout padding , textview child. when textview selected, want highlighted area extend include padding of parent, entire relativelayout highlighted.
main.xml
<textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello world, myactivity" android:textsize="30dp" android:clickable="true" android:background="@drawable/myback" /> myback.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@color/gray" /> <item android:state_focused="true" android:drawable="@color/gray" /> <item android:state_pressed="true" android:drawable="@color/gray" /> </selector> myactivity.java
package com.example.textviewpadding; import android.app.activity; import android.os.bundle; public class myactivity extends activity { /** * called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } } 
if want have behaviour, need add padding textview instead of relativelayout keep padding on parent @ 0.
Comments
Post a Comment