I am creating a table with some table row in it and each tablerow contains three tabledata(textview). I am using the following color scheme.
TableLayoutBackgroundColor: White TableRowBackgroundColor:Black TableDataBackgroundColor(textview): white
setting ma开发者_StackOverflowrging for table row:
TableRow.LayoutParams params = new TableRow.LayoutParams();
params.setMargins(Constants.LEFT_MARGIN, Constants.TOP_MARGIN, Constants.RIGHT_MARGIN,Constants.BOTTOM_MARGIN);Now the problem is when I highlight the tablerow using following code:
tr.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if(hasFocus){
v.setBackgroundColor(Color.GREEN);
}
else
{
v.setBackgroundColor(Color.BLACK);
}
}
});
Only border of the table row is displayed. I want the highlighter over the complete row. Please suggest me how to do it.
Android manages this for you using the State List Drawables mechanism. I wrote a blog entry about how to use State List Drawables. The blog post specifically deals with applying these to a button, but the techniques are much the same for what you're trying to do.
I think that want you want is styles http://developer.android.com/guide/topics/ui/themes.html try to see if is that what you want hope it helped.
Example here with a button http://www.gersic.com/blog.php?id=56
精彩评论