Friday, 15 March 2013

android - Strange behavior in layout of my ActionBarActivity -



android - Strange behavior in layout of my ActionBarActivity -

i got problem didnt seen yet. layout xml file in actionbaractivity shows unusual behavior. background color of linear layout , custom styled actionbar shows different shades of applied color. works expected. here screenshots of problem.

expected result

sometimes getting this

my layout

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <button android:id="@+id/submitbutton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:layout_margin="5dp" android:background="@drawable/login_button_selector" android:text="@string/submit" android:textcolor="@color/white" /> <textview android:id="@+id/titletext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margin="10dp" android:text="@string/add_food" android:textappearance="?android:attr/textappearancelarge" android:textcolor="@color/theme_red" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/submitbutton" android:layout_below="@+id/titletext" android:layout_centerhorizontal="true" android:layout_margin="5dp" android:orientation="vertical" android:weightsum="3" > <!-- time block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1" android:orientation="horizontal" android:weightsum="4" > <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/timetitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/time" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="3" android:weightsum="5" > <!-- <wheel.wheelview android:id="@+id/day" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2.3" /> <wheel.wheelview android:id="@+id/hour" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> <wheel.wheelview android:id="@+id/mins" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> <wheel.wheelview android:id="@+id/ampm" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> --> </linearlayout> </linearlayout> <!-- item block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1" android:orientation="horizontal" android:weightsum="4" > <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/itemtitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/item" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <relativelayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="3" > <spinner android:id="@+id/foodlistspinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_toleftof="@+id/addfooditems" /> <imagebutton android:id="@+id/addfooditems" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignparentright="true" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:background="@drawable/circle_button_selector" android:contentdescription="@string/add_food_item" android:src="@drawable/add_food" /> </relativelayout> </linearlayout> <!-- quantity block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1" android:orientation="horizontal" android:weightsum="4" > <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/quantitytitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/quantity" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="3" android:weightsum="3" > <spinner android:id="@+id/quantitynospinner" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" /> <spinner android:id="@+id/quantitypiecespinner" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </linearlayout> </linearlayout> </linearlayout> </relativelayout>

my custom actionbar

<!-- theme applied application or activity --> <style name="customactionbartheme" parent="@style/theme.appcompat.light.darkactionbar"> <item name="android:actionbarstyle">@style/myactionbar</item> <!-- back upwards library compatibility --> <item name="actionbarstyle">@style/myactionbar</item> </style> <!-- actionbar styles --> <style name="myactionbar" parent="@style/widget.appcompat.light.actionbar.solid.inverse"> <item name="android:background">@color/theme_red</item> <!-- back upwards library compatibility --> <item name="background">@color/theme_red</item> <item name="android:alwaysdrawnwithcache">true</item> <item name="android:displayoptions">showtitle|showhome|homeasup</item> <item name="android:icon">@android:color/transparent</item> </style>

these problems appears in devices. hope can help me out problem.

try way,hope help solve problem.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <textview android:id="@+id/titletext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margin="10dp" android:text="@string/add_food" android:textappearance="?android:attr/textappearancelarge" android:textcolor="@color/theme_red" /> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="5dp" android:orientation="vertical" android:layout_weight="1"> <!-- time block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1"> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.30" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/timetitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/time" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="0.70"> <!-- <wheel.wheelview android:id="@+id/day" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2.3" /> <wheel.wheelview android:id="@+id/hour" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> <wheel.wheelview android:id="@+id/mins" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> <wheel.wheelview android:id="@+id/ampm" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".9" /> --> </linearlayout> </linearlayout> <!-- item block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1"> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.30" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/itemtitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/item" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <relativelayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="0.70" > <spinner android:id="@+id/foodlistspinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_toleftof="@+id/addfooditems" /> <imagebutton android:id="@+id/addfooditems" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignparentright="true" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:background="@drawable/circle_button_selector" android:contentdescription="@string/add_food_item" android:src="@drawable/add_food" /> </relativelayout> </linearlayout> <!-- quantity block --> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginbottom="10dp" android:layout_margintop="10dp" android:layout_weight="1"> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.30" android:background="@color/theme_red" android:gravity="center" > <textview android:id="@+id/quantitytitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/quantity" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@color/white" /> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="5dp" android:layout_weight="0.70"> <spinner android:id="@+id/quantitynospinner" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" /> <spinner android:id="@+id/quantitypiecespinner" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </linearlayout> </linearlayout> </linearlayout> <button android:id="@+id/submitbutton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margin="5dp" android:background="@drawable/login_button_selector" android:text="@string/submit" android:textcolor="@color/white" /> </linearlayout>

android android-layout android-actionbaractivity

No comments:

Post a Comment