Inheriting the android:tint attribute from a ViewGroup - android

If the android:tint attribute is set for a ViewGroup, should it apply to all descendant View's, or does it need to be applied to each individually?
The LinearLayout below (ButtonBar$LabeledButton) contains an ImageView and TextView that each specify their own color state list (CSL).
I'd like to set android:tint once in the ViewGroup so when it is disabled, all its members become disabled and change their tint accordingly (and also without having to override the setEnabled).
resources/layout/buttonbar_labeledbutton_addnew.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="ButtonBar$LabeledButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_AddNew"
style="#style/ButtonBar_LabeledButton">
<ImageView
android:id="#+id/ButtonBar_LabeledButton_Image"
style="#style/ButtonBar_LabeledButton_Image"
android:src="#drawable/v__ic_add_circle_outline_black_24dp"/>
<TextView
android:id="#+id/ButtonBar_LabeledButton_Label"
style="#style/ButtonBar_LabeledButton_Label"
android:text="Add New"/>
</view>
<!--/LinearLayout-->
resources/values/styles.xml
<!--LinearLayout-->
<style name="ButtonBar_LabeledButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">horizontal</item>
<??-item name="android:tint">#color/buttonbar_csl</item-??>
</style>
<!--ImageView-->
<style name="ButtonBar_LabeledButton_Image">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:tint">#color/buttonbar_csl</item>
</style>
<!--TextView-->
<style name="ButtonBar_LabeledButton_Label">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/buttonbar_csl</item>
<!--item name="android:tint">#color/buttonbar_csl</item-->
</style>
ButtonBar.LabeledButton
[Register("ButtonBar$LabeledButton")]
public class LabeledButton : LinearLayout
{
public LabeledButton(Context context, IAttributeSet attributes) : base(context, attributes) { }
public override bool Enabled
{
set
{
var image = FindViewById<ImageView>(Resource.Id.ButtonBar_LabeledButton_Image);
if( image != null )
image.Enabled = value;
var label = FindViewById<TextView>(Resource.Id.ButtonBar_LabeledButton_Label);
if( label != null )
label.Enabled = value;
base.Enabled = value;
}
}
}
Update
Attributes
Every View and ViewGroup object supports their own variety of XML
attributes. Some attributes are specific to a View object (for
example, TextView supports the textSize attribute), but these
attributes are also inherited by any View objects that may extend this
class. Some are common to all View objects, because they are inherited
from the root View class (like the id attribute). And, other
attributes are considered "layout parameters," which are attributes
that describe certain layout orientations of the View object, as
defined by that object's parent ViewGroup object.
android:tint is specific to ImageView, and is ignored. I didn't inspect the attribute set in ButtonBar$LabeledButton's inflation constructor to see if it is at lest present to work with. Declaring a custom attribute would solve this, but then it's assignment to the ImageView and TextView in their now required custom classes' inflation constructors would be obscured (I prefer to leverage the framework as much as possible to minimize any extra, one-off code b/c of the maintenance and potential point-of-failure it introduces).

ButtonBar
public class ButtonBar : LinearLayout
{
public ButtonBar(Context context, IAttributeSet attributes) : base(context, attributes) { }
public override bool Enabled
{
set
{
SetChilderenEnabled(value);
base.Enabled = value;
}
}
private void SetChilderenEnabled(bool value)
{
for (int i = 0; i < ChildCount; i++)
{
GetChildAt(i).Enabled = value;
}
}
[Register("us.sam.views.ButtonBar$LabeledButton")]
public class LabeledButton : LinearLayout
{
private ImageView _buttonIV;
private TextView _labelTV;
private int _buttonIV_src;
private string _labelTV_text;
public override bool Enabled
{
set
{
if (_buttonIV != null)
_buttonIV.Enabled = value;
if (_labelTV != null)
_labelTV.Enabled = value;
base.Enabled = value;
}
}
public LabeledButton(Context context, IAttributeSet attributes) : base(context, attributes)
{
ReadAttributes(context, attributes);
LayoutInflater inflater = LayoutInflater.From(context);
_labelTV = (TextView)inflater.Inflate(Resource.Layout.ButtonBar_LabeledButton_LabelTextView, this, false);
_buttonIV = (ImageView)inflater.Inflate(Resource.Layout.ButtonBar_LabeledButton_ButtonImageView, this, false);
_labelTV.Text = _labelTV_text;
_buttonIV.SetImageResource(_buttonIV_src);
AddViewInLayout(_buttonIV, ChildCount, _buttonIV.LayoutParameters);
AddViewInLayout(_labelTV, ChildCount, _labelTV.LayoutParameters);
}
private void ReadAttributes(Context context, IAttributeSet attributes)
{
Android.Content.Res.TypedArray typedArray = context.ObtainStyledAttributes(attributes, Resource.Styleable.LabeledButton);
_buttonIV_src = typedArray.GetResourceId(Resource.Styleable.LabeledButton_button_imageview_src, 0);
_labelTV_text = typedArray.GetString(Resource.Styleable.LabeledButton_label_textview_text);
typedArray.Recycle();
}
}
}
recordexpandablelistview_groupbuttonbar_trecords.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="us.sam.RecordsView$RecordExpandableListView$GroupButtonBar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RecordExpandableListView_GroupButtonBar_TRecords"
style="#style/RecordExpandableListView_GroupButtonBar">
<!--LinearLayout-->
<us.sam.Views.ButtonBar
android:id="#+id/ButtonBar"
style="#style/ButtonBar">
<include layout="#layout/ButtonBar_LabeledButton_AddNew"/>
</us.sam.Views.ButtonBar>
<ImageView style="#style/ListItem_Divider_Horizontal"/>
</view>
ButtonBar_LabeledButton_AddNew.axml
<?xml version="1.0" encoding="utf-8"?>
<!--LinearLayout-->
<view class="us.sam.views.ButtonBar$LabeledButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_AddNew"
style="#style/ButtonBar_LabeledButton"
button_imageview_src="#drawable/v__ic_add_circle_outline_black_24dp"
label_textview_text="#string/ButtonBar_LabeledButton_LabelTextView_Text_AddNew">
</view>
ButtonBar_LabeledButton_ButtonImageView.axml
<?xml version="1.0" encoding="utf-8"?>
<!--<view class="us.sam.views.ButtonBar$LabeledButton$Button"-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_ButtonImageView"
style="#style/ButtonBar_LabeledButton_ButtonImageView"/>
<!--android:src="#drawable/v__ic_add_circle_outline_black_24dp"-->
ButtonBar_LabeledButton_LabelTextView.axml
<?xml version="1.0" encoding="utf-8"?>
<!--view class="us.sam.views.ButtonBar$LabeledButton$Label"-->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ButtonBar_LabeledButton_LabelTextView"
style="#style/ButtonBar_LabeledButton_LabelTextView"/>
<!--android:text="Add New"-->
styles.xml
<!--LinearLayout-->
<style name="RecordExpandableListView_GroupButtonBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:orientation">vertical</item>
<!--use isChildSelectable() override in BaseExpandableListAdapter instead-->
<!--item name="android:clickable">true</item-->
</style>
<!--LinearLayout-->
<style name="ButtonBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">horizontal</item>
</style>
<!--LinearLayout-->
<style name="ButtonBar_LabeledButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:orientation">horizontal</item>
</style>
<!--ImageView-->
<style name="ButtonBar_LabeledButton_ButtonImageView">
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:tint">#color/button_bar_csl</item>
</style>
<!--TextView-->
<style name="ButtonBar_LabeledButton_LabelTextView">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/button_bar_csl</item>
</style>
<style name="ListItem_Divider_Horizontal">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1px</item>
<item name="android:background">#android:color/black</item>
</style>

Related

Android: changing colour of floating label (hint) in TextInputLayout in error state

I want the floating label of TextInputLayouts to change colour (e.g. to red) when there is an error. I can change the colour of the error text, but it has no effect on the appearance of the floating label (unlike someone in some other thread claimed). I couldn't use selectors for the hint colour to solve this problem either, as there does not seem to be a state defined for errors. Does anyone have any idea how to do this without having to manually program the change on error events/create a new java class (with EditText as parent)?
Here are the stylings I defined:
<style name="EditTextFloatingLabel" parent="#android:style/TextAppearance">
<item name="android:textSize">#dimen/textsize_caption_small</item>
<item name="android:layout_marginBottom">8dp</item>
<item name="android:textColor">#color/input_text_color</item>
</style>
<style name="EditTextErrorText" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/error_color</item>
</style>
<style name="EditTextLayout">
<item name="android:textColorHint">#color/placeholder_color</item>
<item name="android:background">#drawable/input_field_background</item>
<item name="android:paddingBottom">#dimen/default_margin_bottom</item>
<item name="android:paddingStart">#dimen/default_margin_left</item>
<item name="android:paddingEnd">#dimen/default_margin_right</item>
</style>
<style name="EditTextTheme">
<item name="android:imeOptions">actionDone</item>
<item name="android:maxLines">1</item>
<item name="colorControlNormal">#color/primary_line_color</item>
<item name="colorControlActivated">#color/nordea_blue</item>
<item name="android:colorControlHighlight">#color/error_color</item>
<item name="android:textColorPrimary">#color/input_field_text</item>
<item name="android:textSize">#dimen/textsize_caption</item>
<item name="android:textColorHint">#color/placeholder_color</item>
</style>
<style name="EditText">
<item name="android:theme">#style/EditTextTheme</item>
<item name="android:textCursorDrawable">#drawable/cursor_blue</item>
<item name="android:paddingTop">#dimen/default_padding_top</item>
<item name="android:paddingStart">#dimen/payment_text_input_padding</item>
</style>
Usage:
<android.support.design.widget.TextInputLayout
android:id="#+id/input_field_error_wrapper_light"
style="#style/EditTextLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/testlogin_text_input_end_padding"
android:layout_marginStart="#dimen/testlogin_text_input_start_padding"
android:paddingTop="#dimen/default_padding_top"
app:hintTextAppearance="#style/EditTextFloatingLabel"
app:errorTextAppearance="#style/EditTextErrorText"
app:errorEnabled="true">
<EditText
android:id="#+id/input_field_light_error"
style="#style/EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#Input Field Disabled Light"
android:imeOptions="actionDone"
/>
</android.support.design.widget.TextInputLayout>
And this is what I see:
As I needed to perform some other actions as well when the layout was in error state, I decided to go with the solution of creating a custom error state and a custom TextInputLayout which can enter this state.
Code:
Defining the new error state in res/values/attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<!-- custom states -->
<declare-styleable name="ErrorState">
<attr name="state_error" format="boolean" />
</declare-styleable>
</resources>
ErrorStateTextInputLayout class:
public class ErrorStateTextInputLayout extends TextInputLayout {
private boolean hasError = false;
private static final int[] ERROR_STATE = new int[]{R.attr.state_error};
public ErrorStateTextInputLayout(Context context) {
super(context);
}
public ErrorStateTextInputLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ErrorStateTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
#Override
protected int[] onCreateDrawableState(int extraSpace) {
int[] state = super.onCreateDrawableState(extraSpace + 1);
if (hasError) {
mergeDrawableStates(state, ERROR_STATE);
}
return state;
}
#Override
public void setError(#Nullable CharSequence error) {
if (error == null) {
setHasError(false);
} else {
setHasError(true);
}
super.setError(error);
}
public void setHasError(boolean error) {
this.hasError = error;
refreshDrawableState();
}
}
Selector for setting the hint text colour:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:color="#color/disabled_text_color" android:state_enabled="false" />
<item android:color="#color/error_color" app:state_error="true" />
<item android:color="#color/input_text_color" android:state_focused="true" />
<item android:color="#color/placeholder_color" />
</selector>
This blog post helped me a lot: http://code.neenbedankt.com/example-of-custom-states-in-android-components/
Try this..solid_red floating color.....
<style name="TextLabelInput" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#color/solid_red</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#color/solid_red</item>
<item name="android:duration">200</item>
<item name="android:textColorHighlight">#color/solid_red</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#color/solid_red</item>
<item name="colorControlNormal">#color/solid_red</item>
<item name="colorControlActivated">#color/solid_red</item>
<item name="colorPrimary">#color/solid_red</item>
<item name="colorPrimaryDark">#color/solid_red</item>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
app:errorTextAppearance="#style/TextLabelInput"
>
hint text color manage over your main theme
which are colorPrimary and colorAccent
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>

Popup menu divider for App compat theme

I used app compat theme style .
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:itemTextAppearance">#style/myCustomMenuTextApearance</item>
<item name="android:listPopupWindowStyle">#style/PopupMenuStyle</item>
</style>
<style name="PopupMenuStyle" parent="Widget.AppCompat.ListPopupWindow">
<item name="android:divider">#drawable/devider</item>
<item name="android:dividerHeight">2dp</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#color/search_panel_color</item>
<item name="android:textColor">#color/activity_button_text_color</item>
<item name="android:shadowColor">#color/activity_theam_color</item>
</style>
<style name="myCustomMenuTextApearance" parent="#android:style/TextAppearance.Widget.TextView.PopupMenu">
<item name="android:textColor">#color/activity_theam_color</item>
</style>
I want to add a divider in my menu item.
I've tried so many things, but the divider is not applying...
Is there any way to show the divider?
I also have the same problem. The solution is like this:
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:divider">#000000</item>
<item name="android:dividerHeight">1dp</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
</style>
You can also refer to the following link:
How to add dividers between specific menu items?
I have one solution.you can design popup as per your choice by programming.use below code to display popup menu.
private ListPopupWindow listPopupWindow;
listPopupWindow = new ListPopupWindow(getApplicationContext());
listPopupWindow.setWidth(400);
listPopupWindow.setDropDownGravity(Gravity.CENTER);
listPopupWindow.setAdapter(new listpopupadapter(a, type));
listPopupWindow.setAnchorView(v);
listPopupWindow.show();
Here listpopupadapter is class to design your list as it below.
public class listpopupadapter extends BaseAdapter {
ArrayList<String> a;
String type;
public listpopupadapter(ArrayList<String> a, String type) {
this.a = a;
this.type = type;
}
#Override
public int getCount() {
return a.size();
}
#Override
public Object getItem(int position) {
return getItem(position);
}
#Override
public long getItemId(int position) {
return position;
}
#SuppressLint("ViewHolder")
#Override
public View getView(final int position, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
View root = LayoutInflater.from(parent.getContext()).inflate(
R.layout.raw_filter, null);
}
}
From your theme style, I guessed you used Toolbar. Is your menu popup is showed from Toolbar? If so, you can customize as the following step.
Define the theme
<style name="AppToolbarPopupTheme" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="android:dropDownListViewStyle">#style/AppDropDownListViewStyle</item>
</style>
<style name="AppDropDownListViewStyle" parent="Widget.AppCompat.ListView.DropDown">
<item name="android:divider">#drawable/line_divider</item>
<item name="android:dividerHeight">1dp</item>
</style>
Then apply the theme to Toolbar
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:popupTheme="#style/AppToolbarPopupTheme">
</android.support.v7.widget.Toolbar>
if you haven't found the answer to this question then this is how it worked for me using the style:
<style name="PopupMenu">
<item name="android:itemBackground">#color/background_medium_gray</item>
<item name="android:background">#android:color/transparent</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/BackgroundGray</item>
<item name="android:dividerHeight">1dp</item>
</style>
Context context = new ContextThemeWrapper(getActivity(), R.style.PopupMenu);
final PopupMenu popupMenu = new PopupMenu(context, view);
final MenuInflater menuInflater = popupMenu.getMenuInflater();
I suggest you add dummy groups,try this way
<group>
<!--add it like as a separator-->
<item
android:title=""
android:showAsAction="always"
android:enabled="false" />
</group>
Using a Material theme removes dividers.May be this is the simple solution to this problem.
You can try this or any holo theme (i.e #android:style/Widget.ListPopupWindow) to get divider effect in popup
<!-- Change Overflow Menu ListView Divider Property -->
<style name="PopupMenuListView" parent="android:Widget.ListPopupWindow">
<item name="android:divider">#FF0000</item>
<item name="android:dividerHeight">2dp</item>
</style>
I've made a driver app that needed a popup the ride was coming, at that time I used this one. So please try this one. Maybe it will help.
<activity
android:name="driver_activity_name
android:theme="#android:style/Theme.Translucent.NoTitleBar" />

Howto customize CCL (Cast Companion Library) controller dialog

I'm trying to customize casting controller dialog and I have problems changing dialog's title style. I've implemented it like CCL library does but without success.
This is my relevant code:
VideoMediaRouteControllerDialog.java
public VideoMediaRouteControllerDialog(Context context) {
super(context, xxx.xxx.R.style.TTNCastDialog);
...
}
VideoMediaRouteControllerDialogFragment.java
public class VideoMediaRouteControllerDialogFragment extends MediaRouteControllerDialogFragment {
#Override
public VideoMediaRouteControllerDialog onCreateControllerDialog(Context context, Bundle savedInstanceState) {
VideoMediaRouteControllerDialog customControllerDialog = new VideoMediaRouteControllerDialog(context);
customControllerDialog.setVolumeControlEnabled(false);
return customControllerDialog;
}
}
VideoMediaRouteDialogFactory.java
public class VideoMediaRouteDialogFactory extends MediaRouteDialogFactory {
#Override
public VideoMediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
return new VideoMediaRouteControllerDialogFragment();
}
}
styles.xml
<style name="TTNCastDialog" parent="#android:style/Theme.Dialog">
<item name="android:windowTitleStyle">#style/TTNCastDialogWindowTitle</item>
</style>
<style name="TTNCastDialogWindowTitle">
<item name="android:textSize">22sp</item>
<item name="android:textColor">#color/ccl_mr_custom_title</item>
</style>
styles.xml(v21)
<style name="TTNCastDialog" parent="android:Theme.Material.Dialog">
<item name="android:windowTitleStyle">#style/TTNCastDialogWindowTitle</item>
</style>
I've taken a look at MediaRouteThemeHelper's getButtonTextColor method
and it returns accent color instead of primary color. My application theme extends of Theme.AppCompat.Light.NoActionBar
I've tried this way too
styles.xml
<style name="TTNCastDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowTitleStyle">#style/TTNCastDialogWindowTitle</item>
</style>
<style name="TTNCastDialogWindowTitle">
<item name="android:textSize">22sp</item>
<item name="android:textColor">#color/ccl_mr_custom_title</item>
</style>
But it did not work.
Any suggestions?
Thanks

Set style programmatically does not work?

This is the code of a compound view I wrote. It uses android.support.v7.widget.CardView as parent class:
public class ItemListItem extends CardView {
TextView tvName;
ImageView ivIcon;
public ItemListItem(Context context) {
super(context, null, R.style.GreenCardView);
LayoutInflater.from(context).inflate(R.layout.item_list_item, this, true);
tvName = (TextView) findViewById(R.id.tvName);
ivIcon = (ImageView) findViewById(R.id.ivIcon);
}
public void setItem(Item item)
{
tvName.setText(item.getName());
}
}
Although I'm adding a custom style (R.style.GreenCardView) to the super constructor call at line 7, it initializes every instance of this class with the default white style. Why is this the case?
edit:
style
<style name="GreenCardView" parent="CardView.Dark">
<item name="contentPadding">#dimen/default_margin</item>
<item name="cardBackgroundColor">#color/guiColor</item>
<item name="cardElevation">#dimen/cardElevation</item>
<item name="cardCornerRadius">#dimen/cardCornerRadius</item>
<item name="android:foreground">?android:attr/selectableItemBackground</item>
</style>
The third argument to the View constructor needs to be a theme attribute, e.g. R.attr.myCardViewStyle. You will need to specify the value of the attribute in your app theme and define the attribute in attrs.xml.
res/values/attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<attr name="myCardViewStyle" format="reference" />
</resources>
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<style name="AppTheme" parent="...">
...
<item name="myCardViewStyle">#style/GreenCardView</item>
</style>
</resources>

How to change background color of ListView item?

There is the following method:
#Override
public void mark() {
ImageView image=(ImageView)view.findViewById(R.id.listItemRepeatingTypeImage);
image.setBackgroundColor(Color.RED);
image.invalidate();
Log.e("event", "mark");
view.setBackgroundColor(Color.GREEN);
view.invalidate();
}
As you can see, I try to change background color for View and ImageView (view is an item of ListView). This event becomes, but there is no new background. How can I fix it?
Try to apply this style to your ListView:
<style name="List">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:background">#FFFFFF</item>
<item name="android:dividerHeight">1dp</item>
<item name="android:divider">#CCCCCC</item>
<item name="android:cacheColorHint">#FFFFFF</item>
<item name="android:listSelector">#00000000</item>
</style>
And in your xml layout this:
<ListView
android:id="#+id/listView"
style="#style/List"
android:paddingTop="1dp"/>

Categories

Resources