landscape mode border image in edittext not working - android

you can refer to this code.
Border color of Edit Text is set to some color.
working fine in portratait mode.
Why i can't see the same color/image in landsacpe mode??In landscape mode when soft key is open then edit text color become red(default)..where can i locate that red border scalable image??
ny idea??
below is my layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/edit1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/edit1_text"
android:inputType="text"
android:background="#drawable/edit_text"
/>
<EditText
android:id="#+id/edit2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/edit2_text"
android:inputType="text"
android:background="#drawable/edit_text"
/>
</LinearLayout>
and here is #drawable/edit_text file code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false"
android:state_enabled="true"
android:drawable="#drawable/textfield_default" />
<item
android:state_window_focused="false"
android:state_enabled="false"
android:drawable="#drawable/textfield_disabled" />
<item
android:state_pressed="true"
android:drawable="#drawable/textfield_pressed" />
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="#drawable/textfield_selected" />
<item
android:state_enabled="true"
android:drawable="#drawable/textfield_default" />
<item
android:state_focused="true"
android:drawable="#drawable/textfield_disabled_selected" />
<item
android:drawable="#drawable/textfield_disabled" />
</selector>

#Mr.Singh - When I executed your code in my device, I am getting edit text border even in landscape mode.Please check....

Related

android:ListSelector doesn't work on my ListView

I want to have an onClick that the chatlist-item changes it's color when clicked/focused. I don't want to use any Java code if possible.
I tried this:
chatlist_layout.xml
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:background="#drawable/round_corners"
android:listSelector="#drawable/selector">
</ListView>
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="#color/ripple_material_light" /> <!-- focused -->
<item android:state_focused="true" android:state_pressed="true" android:drawable="#color/green_hsrt_1_default_CMYK_100_10_55_0" /> <!-- focused and pressed-->
<item android:state_pressed="true" android:drawable="#color/grey" /> <!-- pressed -->
<item android:drawable="#color/black" /> <!-- default -->
</selector>
what am I doing wrong?
Any kind of help will be greatly appreciated
The problem may be in ListView background. So try to add android:drawSelectorOnTop="true"

cannot update custom ratingbar android

I am trying to write code based on which I should update the rating in steps of 1 as I am getting integer values for Rating. Here is the code for the same
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="3dp" >
<RatingBar
android:id="#+id/PriceRating"
style="#style/foodRatingBarSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:isIndicator="true"
android:numStars="1"
android:stepSize="0.25"
android:max="5" />
</LinearLayout>
Here is the code in the style file:
<style name="foodRatingBarSmall" parent="#android:style/Widget.RatingBar">
<item name="android:progressDrawable">#drawable/foodratingbar_full</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
</style>
Here are the foodratingbar file
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/background" android:drawable="#drawable/foodratingbar_fill"
/>
<item android:id="#+id/secondaryProgress"
android:drawable="#drawable/foodratingbar_fill" />
<item android:id="#+id/progress" android:drawable="#drawable/foodratingbar_empty" />
</layer-list>
And here is the code for foodratingbar_fill:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="#drawable/dollar" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="#drawable/dollar" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="#drawable/dollar" />
<item android:drawable="#drawable/dollar" />
</selector>
where dollar is a png image
The problem with my code is that I cannot get it to update to the required number of stars and I see vague values of the number of stars being displayed on android. I would like to know how I can display one dollar image for 1 rating with a maximum of 5

Change listview row item background color and text color in android

In my custom listview, I have used relativelayout and inside that added 2 textviews vertically.
Background image is set to relativelayout. Now I want to change background image as well as textcolor of textview when listview item is pressed.
How to do this, any one have idea?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/item_bg"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textColor="#color/orange"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="10dip"
android:layout_marginLeft="10dip"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="20dip"
android:layout_marginTop="8dip"
android:ellipsize="end"
android:maxLines="3"
android:duplicateParentState="true" <!-- this is a line to use..-->
android:textColor="#color/_textcolor"
android:textSize="14sp" >
</TextView>
item_bg.xml inside res/drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="#drawable/bannerbg_hover"/>
<item android:state_focused="true" android:drawable="#drawable/bannerbg_hover" />
<item android:state_selected="true" android:drawable="#drawable/bannerbg_hover"/>
<item android:drawable="#drawable/bannerbg"/>
</selector>
_textcolor.xml inside res/color/ folder:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:color="#color/white"/>
<item android:state_focused="true" android:color="#color/white" />
<item android:state_selected="true" android:color="#color/white"/>
<item android:color="#color/dark_blue"/>
</selector>
Concerning the background, you should create a StateList Drawable and set it as the background of your rows.
Ex of a such drawable (could be named background_selector.xml) :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#color/color1" /> <!-- pressed -->
<item android:drawable="#color/color2" /> <!-- default -->
</selector>
And in the layout declaration of your row :
...
android:background="#drawable/background_selector"
...
Use the same way for your text with the Color State List

Android Trackball on Custom Dialog

I have a custom dialog which extends the Dialog class and a simple custom layout like the one from below:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:drawable/list_selector_background"
>
<TextView
android:id="#+id/text_view"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:background="#color/transparent"
android:textColor="#color/black"
android:textSize="16sp"
android:focusable="true"/>
My problem is that the trackball makes the text not visible when a row is selected like in the attached image.
The list_selector_background code is from Android and it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<item android:state_window_focused="false" android:drawable="#color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="#drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="#drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="#drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="#drawable/list_selector_background_transition" />
<item android:state_focused="true" android:drawable="#drawable/list_selector_background_focus" />
And my ListView xml code is this:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="true"
android:background="#color/white"
android:cacheColorHint="#color/transparent">
</ListView>
I saw that on an AlertDialog (the one from Android) is working okay. What should I do to solve this problem?
try this: remove "android" text from this line. like;
android:background="#drawable/list_selector_background"
add in list view
android:cacheColorHint="#android:color/transparent"
android:drawSelectorOnTop="false"
android:listSelector="#android:color/transparent"
android:fadingEdge="none"
this one work for me

How to change the color of button after click?

I create button with background color but when i click on it, it's not show anything.
I need to show different color on button after click because user need to know button is
Click.
I don't understand how to do this?
Give me suggestion.
here is my button code.
<Button android:textSize="15px"
android:id="#+id/button9"
android:gravity="center|bottom"
android:textColor="#color/myWhiteColor"
android:drawableTop="#drawable/math"
android:text="#string/HomePage_Math"
android:background="#color/myMaroonColor"
android:layout_width="54dp"
android:layout_height="wrap_content" ></Button>
//XML file saved at res/drawable/button_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
//This layout XML will apply the color list to a View:
<Button android:textSize="15px"
android:id="#+id/button9"
android:gravity="center|bottom"
android:textColor="#color/myWhiteColor"
android:drawableTop="#drawable/math"
android:text="#string/HomePage_Math"
android:background="#drawable/button_bg"
android:layout_width="54dp"
android:layout_height="wrap_content" ></Button>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#color/colorPrimaryDark" />
<item android:state_focused="true" android:drawable="#android:color/holo_green_dark" />
<item android:drawable="#color/colorCartButton" />
</selector>
This will work

Categories

Resources