我有一个RelativeLayout
带填充物和一个TextView
孩子。选择时TextView
,我希望突出显示的区域扩展到包括父级的填充,以便整个RelativeLayout
突出显示。
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 the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}