Italic font changes TextView layout in Galaxy S5 - android

I have a very strange behavior of TextView layout which only happens in Galaxy S5.
The problem is that when I set the text style to italic, the TextView that aligned with the screen right side seems to get out form the screen (the TextView has a rectangle border).
This strange problem appears only in Galaxy S5! in all other devices that I tried my application and even on other Samsung like S3 and S4 everything looks just fine!
Can anyone explain this behavior and maybe can offer some solutions to this ?
I do have screenshots but I still can't publish images here.
Please refer to layout xml as is! I just comment the textStyle="italic" and then everything looks great!
Only on S5 guys..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/Black" >
<LinearLayout
android:id="#+id/timerLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#drawable/nicetextframe" >
<ImageView
android:id="#+id/imRecording"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_recording"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="#+id/tvTimer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_above="#+id/gpsDataTable"
android:layout_weight="5"
android:background="#drawable/nicetextframe"
android:gravity="center"
android:text="00:00"
android:textColor="#color/YellowGreen"
android:textSize="35sp"
android:textStyle="italic" />
Ï
</LinearLayout>
<LinearLayout
android:id="#+id/guegesLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/timerLayout"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvSpeed"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_above="#+id/gpsDataTable"
android:layout_weight="1"
android:background="#drawable/nicetextframe"
android:gravity="center"
android:text="0.0"
android:textColor="#color/YellowGreen"
android:textSize="40sp"
android:textStyle="italic"/>
<TextView
android:id="#+id/tvDistance"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_above="#+id/gpsDataTable"
android:layout_weight="1"
android:background="#drawable/nicetextframe"
android:gravity="center"
android:text="0.0"
android:textColor="#color/YellowGreen"
android:textSize="40sp"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:id="#+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/tableRow1"
android:layout_below="#+id/guegesLayout"
android:background="#drawable/nicesqureframe"
android:orientation="horizontal" >
<fragment
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="20dp"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/black_gradient" >
<ToggleButton
android:id="#+id/btStartStop"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/button_selector"
android:textColor="#color/DarkGreen"
android:textOff="#string/NewTrip"
android:textOn="#string/StopTrip"
android:textStyle="bold" />
<Button
android:id="#+id/btClose"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/button_selector"
android:text="#string/Close"
android:textColor="#color/DarkGreen"
android:textStyle="bold" />
</TableRow>
</RelativeLayout>

Related

Android app not showing complete Samsung S3 mini

I'm new to android and working on my first app which is from a online course project. The fact is that on Android Studio the app is working fine, but I built the apk file to test it on my phone (Samsung galaxy s3 mini). On device, the app is not showing complete as it is missing an edit text and a button at the bottom of the layout. I'm attaching two screenshots, the first one of the app running on the emulator, and the one running on my smartphone.
App running in the emulator:
App running on the smartphone:
Layout code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.linfosoft.hangdroid.GameActivity"
tools:showIn="#layout/activity_game">
<ImageView
android:layout_width="wrap_content"
android:layout_height="350dp"
android:id="#+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/hangdroid_0"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:background="#drawable/gradient_background"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:id="#+id/layoutAddLetter"
android:layout_marginTop="90dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Ingresa letra"
android:id="#+id/textView2"
android:layout_gravity="center_vertical"
android:layout_marginLeft="40dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:maxLength="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Revisar"
android:id="#+id/button2"
android:onClick="introduceLetter" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="false"
android:layout_alignParentTop="false"
android:layout_marginTop="20dp"
android:id="#+id/layoutLetters">
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView7"
android:layout_marginTop="150dp"
android:layout_marginLeft="20dp"
android:textColor="#color/red" />
</RelativeLayout>
put your xml code within of a ScrolView:
<ScrollView
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
your xml
</ScrollView>
or add weight at your layouts:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</LinearLayout>
Your Hangman picture is really height as it has a value of 350dp
Please check this code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.linfosoft.hangdroid.GameActivity"
tools:showIn="#layout/activity_game">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="350dp"
android:id="#+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/hangdroid_0"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:background="#drawable/gradient_background"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:id="#+id/layoutAddLetter"
android:layout_marginTop="90dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Ingresa letra"
android:id="#+id/textView2"
android:layout_gravity="center_vertical"
android:layout_marginLeft="40dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:maxLength="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Revisar"
android:id="#+id/button2"
android:onClick="introduceLetter" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="false"
android:layout_alignParentTop="false"
android:layout_marginTop="20dp"
android:id="#+id/layoutLetters">
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView7"
android:layout_marginTop="150dp"
android:layout_marginLeft="20dp"
android:textColor="#color/red" />
</RelativeLayout>
<ScrollView>
As you see I used ScrollView, but scrolling a view would be enabled ONLY if a device would not have enough space to take everything on its screen.
In the other case it would be like any other static layout.
It doesn't mean that you would scroll it on every device or your game would be less attractive ;-)
Also you can change height of your picture to wrap_content, bu I suppose that author if this tutorial make this height by value, because the picture in the reality is much bigger than that with height of 350dp.

Layout doesn't fill frame layout in android 2.3

I have a FrameLayout with two LinearLayouts inside. For Android version 4.x it works fine but for version 2.3 second LinearLayout doesn't fill FrameLayout vertically. Can anyone tell me why? Btw I know I set second LinearLayout as invisible but I show it up later in code :)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/list_left_border">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/maincontrols"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="85"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/left_border_grey_width"
android:layout_marginStart="#dimen/left_border_grey_width"
android:layout_marginTop="10dp"
android:textSize="#dimen/choose_level_list_item_name_text_size"
android:textColor="#ff0000"
android:paddingLeft="5dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="#dimen/choose_level_list_item_description_text_size"
android:paddingLeft="5dp"
android:layout_marginLeft="#dimen/left_border_grey_width"
android:layout_marginStart="#dimen/left_border_grey_width"/>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="15"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:id="#+id/progressBarContainer">
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/buttons"
android:visibility="invisible"
android:alpha="0.7" >
<Button
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".45"
android:text="#string/learn2"
android:id="#+id/buttonLearn"
android:layout_marginTop="0dp"
android:background="#drawable/button_learn_border"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:textColor="#000000"
android:gravity="center" />
<Button
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".45"
android:text="#string/test2"
android:id="#+id/buttonTest"
android:background="#drawable/button_test_bg"
android:textColor="#000000"
android:layout_marginTop="0dp"
android:gravity="center" />
</LinearLayout>
</FrameLayout>

How to design a xml file to display in more screen

I'm new android programmer, I designed a page screen of 4". I've initialized with "dp" unit of measurement.
but when I run my project in screen of 10" or 7" or 3"2 components go wrong.
I learned dp is for all of screen, but I don't know why my page not be set to all of screens.
If you could include any code of your XML file, that would be very helpful.
Aside from that, I believe you haven't set android:layout_width and android:layout_height so you are getting odd looking sizes for the other display sizes of you XML.
Add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your <RelativeLayout>
e.g.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
...
>
If you do in fact have this or it does not help with your issue
, then please respond with an example of your code.
my xml file is here, but I set visibility of one linearlayout to gone
and when user touch button the linearlayout will be visible and another linearlayout will be gone
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainLayout"
android:background="#drawable/darirann"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layoutTerm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<ScrollView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_marginTop="200dp"
android:layout_height="150dp">
<LinearLayout
android:padding="5dp"
android:layout_width="wrap_content"
android:background="#ffffff"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/firstpageabout" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/btnLoad"
android:layout_gravity="center"
android:textColor="#ffffff"
android:background="#114E7D"
android:gravity="center"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:text="ادامه"/>
</LinearLayout>
<LinearLayout
android:id="#+id/layoutData"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone">
<Spinner
android:id="#+id/spState"
android:paddingRight="5dp"
android:layout_gravity="center"
android:background="#D3D3D3"
android:textSize="12sp"
android:layout_marginTop="200dp"
android:layout_width="150dp"
android:gravity="center"
android:layout_height="40dp" />
<Spinner
android:id="#+id/spCity"
android:paddingRight="5dp"
android:layout_gravity="center"
android:background="#D3D3D3"
android:textSize="12sp"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_width="150dp"
android:layout_height="40dp" />
<Button
android:layout_gravity="center"
android:id="#+id/btnNext"
android:textColor="#ffffff"
android:background="#114E7D"
android:layout_marginTop="10dp"
android:layout_width="120dp"
android:layout_height="40dp"
android:text="مرحله ی بعد" />
<Button
android:layout_gravity="center"
android:id="#+id/btnUpdate"
android:visibility="invisible"
android:textColor="#ffffff"
android:background="#840101"
android:layout_marginTop="80dp"
android:layout_width="200dp"
android:layout_height="40dp"
android:text="دریافت نسخه ی جدید این برنامه" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgAds"
style="?android:attr/buttonStyleSmall"
android:layout_width="150dp"
android:layout_height="75dp"
android:visibility="gone"
android:layout_gravity="center_horizontal|center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Right Drawer Layout out of margin

I'm using DrawerLayout in my app.
I test it in Samsung note 3 and samsung S4 everything is fine. But when it test to Samsung S3 the layout has messed up.
Please refer to below image
Test in Samsung Note 3 and Samsung S4 :
http://www.imagesup.net/?di=1514046988962
Test in Samsung S3 :
http://www.imagesup.net/?di=14140469921515
My xml layout code as following below :
<include
android:id="#+id/shopping_cart_slider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
layout="#layout/shopping_cart_redesign"
android:choiceMode="singleChoice" />
And this is layout that included :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_register_text" >
<LinearLayout
android:id="#+id/shopping_cart_redesign_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/grey_register_text"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical" >
<ImageView
android:id="#+id/logo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:contentDescription="#string/desc_list_item_icon" />
<com.zukami.apps.dev.blynk.util.CustomListView
android:id="#+id/list_shopping_cart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/logo_image"
android:background="#android:color/white"
android:divider="#color/grey_register_text"
android:dividerHeight="1dp" >
</com.zukami.apps.dev.blynk.util.CustomListView>
<View
android:id="#+id/border"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/list_shopping_cart"
android:layout_marginTop="5dp"
android:background="#color/grey_register_text" />
<RelativeLayout
android:id="#+id/total_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/border"
android:layout_marginTop="10dp" >
<LinearLayout
android:id="#+id/total_text_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="2dp"
android:orientation="vertical" >
<TextView
android:id="#+id/total_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/total"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/merchandise_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/merchandise_total"
android:textSize="15sp" />
<TextView
android:id="#+id/loyalty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="#string/loyalty"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/total_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/total_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/border_two"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/total_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:background="#android:color/black" />
<Button
android:id="#+id/confirm_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/border_two"
android:layout_marginBottom="2dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:background="#drawable/grey_shopping_cart_button"
android:gravity="center|center_horizontal"
android:text="#string/confirm_order"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="#+id/space"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/confirm_button"
android:layout_marginTop="5dp" />
</RelativeLayout>
<ImageView
android:id="#+id/receipt_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/info_container"
android:layout_marginTop="-6dp"
android:contentDescription="#string/icon"
android:src="#drawable/receipt_border" />
<TextView
android:id="#+id/receipt_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/receipt_border"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#android:color/white"
android:textSize="15sp" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLargeInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Kindly advise what's wrong with this layout because I have set all width to match parent but still not working in all device.
Really appreciate for any kind help.
Hmm, I cant see anything wrong right now.
One time I had a problem that anything on my code was wrong, but on devices running API 18+ the android:gravity="center_vertical" simple did not work, but I fix it just changing the value of android:target="18" to android:target="16". I choose "16" because it was the version of my Android that was running without any problems.
I don't know if this is your case, but change the android target property at Android Manifest.xml, just give it a try (y)

TextView contents not centering correctly on android 4.2.2

The image on the right (2.3.3) presents my view as i would like it to, however i can't get it to look right on 4.2.2. Notice how the text in the textview is not vertically centered. I've tried both in the emulator and on Galaxy S4. Also, the eclipse ADT preview of XML files shows it centered correctly.
The view is used in a listview.
How do i center the text in my textview so it looks the same on all android versions?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="16dp" >
<ImageView android:id="#+id/fylke_vapen"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/fylke_buskerud" />
<TextView android:id="#+id/fylke_navn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#id/fylke_vapen"
android:layout_alignBottom="#id/fylke_vapen"
android:layout_alignTop="#id/fylke_vapen"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:textSize="24sp"
android:maxLines="1"
android:text="Placeholder text" />
<CheckBox android:id="#+id/star"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="#id/fylke_vapen"
android:layout_alignBottom="#id/fylke_vapen"
android:gravity="center"
android:button="#drawable/star_checkbox"
android:focusable="false" />
</RelativeLayout>
You should to remove android:layout_alignBottom and android:layout_alignTop attributes.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="16dp" >
<ImageView android:id="#+id/fylke_vapen"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:scaleType="fitCenter"
android:src="#drawable/userpic_sidebar_default" />
<TextView android:id="#+id/fylke_navn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#id/fylke_vapen"
android:layout_toLeftOf="#id/star"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:textSize="24sp"
android:maxLines="1"
android:text="Placeholder text" />
<CheckBox android:id="#+id/star"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:button="#drawable/star_checkbox"
android:gravity="center"
android:focusable="false" />
</RelativeLayout>
Well, i solved my issue by wrapping the textview in a linearlayout which centers the textview via gravity.
There seems to be a bug where you can't match_parent on textview within a listview on 4.2.2 (i've not tested any other versions than 4.2.2 and 2.3.3)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="16dp" >
<ImageView android:id="#+id/fylke_vapen"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentLeft="true"
android:scaleType="fitCenter"
android:src="#drawable/fylke_buskerud" />
<CheckBox android:id="#+id/star"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentRight="true"
android:button="#drawable/star_checkbox"
android:focusable="false" />
<LinearLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_toRightOf="#id/fylke_vapen"
android:layout_toLeftOf="#id/star"
android:layout_alignBottom="#id/fylke_vapen"
android:layout_alignTop="#id/fylke_vapen"
android:paddingLeft="16dp"
android:gravity="left|center" >
<TextView android:id="#+id/fylke_navn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:maxLines="1"
android:text="Placeholder text" />
</LinearLayout>
</RelativeLayout>
// try this way,hope this will help you...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:padding="10dp" >
<ImageView
android:id="#+id/fylke_vapen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="#+id/fylke_navn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:maxLines="1"
android:gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Placeholder text" />
</LinearLayout>
<CheckBox
android:id="#+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/ic_launcher"
android:focusable="false" />
</LinearLayout>

Categories

Resources