Android app not showing complete Samsung S3 mini - android

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.

Related

Xamarin Listview doesnt follow the rtl direction

Helly guys.
Im learning xamarin and trying to make a basic food app for android. This app is in RTL direction. Now i have a Listview in my main content which contains a list of custom layouts. Here is a look at this custom layout. I is RTL in Xamarin Designer windows.
And this is the layout axaml code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:textDirection="rtl">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<ImageView
android:src="#drawable/rating4"
android:id="#+id/imgRating"
android:layout_width="70dp"
android:layout_height="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp" />
<ImageView
android:src="#drawable/defaultthumbnail"
android:id="#+id/imgThumbnail"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<TextView
android:text="10,000 تومان"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:id="#+id/foodPrice"
android:layout_marginLeft="5dp"
android:textDirection="rtl" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp">
<TextView
android:text="نام غذا"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtFoodName"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:text="توضیحات غذا"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:id="#+id/txtFoodDesc" />
<TextView
android:text="تاریخ"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtDate"
android:textSize="8sp"
android:textAllCaps="false" />
<TextView
android:text="آشپز"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtCook"
android:textSize="8sp"
android:textAllCaps="false" />
</LinearLayout>
And this is my main layout which this listview is in it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="#+id/mainContentLayout"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/app_bar_main"
android:layoutDirection="rtl"
android:textDirection="rtl">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainContentListView"
android:layoutDirection="rtl"
android:textDirection="rtl" />
</LinearLayout>
But when i run this this is what i get
as you can those 2 linearlayouts inside are following the rule of RTL but are inverted.
I had the same problem and I fixed it by adding the following in the application's manifest:
<manifest>
<application>
android:supportsRtl="true"
</application>
</manifest>
default emulator and preview didn't work well with "RTL" languages. try to test on real android device or try xamarin live player.
also some android devices force "ltr" when the android interface language is English,try to change android language to a "RTL' language.
About android:supportsRtl="true", you can refer to this, it's default value is false.
From your layout axaml code, it displays in VS's Design as:
But it display in AS's Design as:
It is same as the result what you have run.
So, there is something wrong with VS's Design.
If I didn't misread your question, what you want to get is:
So, you need change your layout axaml code to below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:textDirection="rtl">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<ImageView
android:src="#drawable/pause"
android:id="#+id/imgRating"
android:layout_width="70dp"
android:layout_height="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp" />
<ImageView
android:src="#drawable/dapao"
android:id="#+id/imgThumbnail"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
<TextView
android:text="10,000 تومان"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:id="#+id/foodPrice"
android:layout_marginLeft="5dp"
android:textDirection="rtl" />
</LinearLayout>
<View
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp">
<TextView
android:text="نام غذا"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtFoodName"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:text="توضیحات غذا"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:id="#+id/txtFoodDesc" />
<TextView
android:text="تاریخ"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtDate"
android:textSize="8sp"
android:textAllCaps="false" />
<TextView
android:text="آشپز"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtCook"
android:textSize="8sp"
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>

Android Diamond Button Layout

I am currently working on a sample application using android studio. I need to design diamond shaped buttons and view them as follows (Screenshots attached). But I don't have an idea how to make this kind of thing with android.
There are be four diamond shaped buttons, and they are be aligned as according to the following screenshot.
Screenshot:
Here is sample code adjust margins according to devices you can use imageView instead buttons
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/firstRow"
android:rotation="-30"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="80dp"
android:layout_height="80dp"
android:text="Button 2"
android:id="#+id/button2" />
<Button
android:layout_width="80dp"
android:layout_height="80dp"
android:text="Button 1"
android:id="#+id/button1"/>
</LinearLayout>
<LinearLayout
android:id="#+id/secondRow"
android:layout_below="#+id/firstRow"
android:rotation="-30"
android:layout_marginTop="24dp"
android:layout_marginLeft="68dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="80dp"
android:layout_height="80dp"
android:text="Button 4"
android:id="#+id/button4" />
<Button
android:layout_width="80dp"
android:layout_height="80dp"
android:text="Button 3"
android:id="#+id/button3"/>
</LinearLayout>
</RelativeLayout>
The easiest way is use .png archives on ImageButtons and display them on a RelativeLayout. You can change positions and adjust them as you wish. If you set the android:background="#android:color/transparent" you can set your form, by playing with the margins (android:layout_marginRight="", android:layout_marginTop="", etc.)
With that I got this:
This is the code I used; it's only necessary .xml, without programmatic changes:
<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"
android:background="#android:color/holo_purple"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="39dp"
android:background="#android:color/transparent"
android:contentDescription="#string/im"
android:src="#drawable/diamond" />
<ImageButton
android:id="#+id/ImageButton03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:contentDescription="#string/im"
android:src="#drawable/diamond" />
<ImageButton
android:id="#+id/ImageButton04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/ImageButton03"
android:layout_below="#+id/imageButton1"
android:layout_marginRight="55dp"
android:layout_marginTop="47dp"
android:background="#android:color/transparent"
android:contentDescription="#string/im"
android:src="#drawable/diamond" />
<ImageButton
android:id="#+id/ImageButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ImageButton03"
android:layout_alignRight="#+id/ImageButton04"
android:layout_marginBottom="66dp"
android:layout_marginRight="5dp"
android:background="#android:color/transparent"
android:contentDescription="#string/im"
android:src="#drawable/diamond" /></RelativeLayout>
Hope it helps.
<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:orientation="vertical"
android:background="#drawable/splash2"
tools:context="com.example.sv.myfoodapplication.view.SplashActivity">
<LinearLayout
android:id="#+id/sp_breakfast"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_above="#+id/sp_desert"
android:layout_alignStart="#+id/sp_vegetable"
android:layout_marginBottom="43dp"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/shape_diamond">
</LinearLayout>
<LinearLayout
android:id="#+id/sp_meat"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignBottom="#+id/sp_vegetable"
android:layout_alignStart="#+id/sp_desert"
android:layout_marginBottom="80dp"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/shape_diamond" >
</LinearLayout>
<LinearLayout
android:id="#+id/sp_vegetable"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignBottom="#+id/sp_desert"
android:layout_alignParentStart="true"
android:layout_marginBottom="83dp"
android:layout_marginStart="19dp"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/shape_diamond" >
</LinearLayout>
<LinearLayout
android:id="#+id/sp_desert"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/shape_diamond">
</LinearLayout>
</RelativeLayout>

why the button is not display and text view?

I am new to android development . I've made a simple demo of login screen. I used Xml to do this and have checked my output on landscape and portrait mode. It looks fine in portrait mode, but on landscape my login button is not visible and I am not able to scroll my view. I used dp in my xml file and I think it is due to dp that I have this problem.
Here are my screen shots to show what is displayed.
This is portrait mode which is looking fine ..
When I rotate my device it moves to landscape, but it is not showing button and below text view? Can I add scroll view ? or can I add in % percentage instead of dp?
Here is my code
<LinearLayout 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"
tools:context=".MainActivity"
android:background="#223399"
android:orientation="vertical">
<TextView
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:text="Login here"
android:gravity="center"
/>
<EditText
android:layout_marginTop="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<EditText
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<Button
android:layout_marginTop="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/loginClick"
android:layout_gravity="center"
/>
<TextView
android:layout_marginTop="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:text="New User?"
android:textColor="#00eeff"
android:gravity="center"
android:id="#+id/regiester_id"
/>
</LinearLayout>
java code
public static final String MyPREFERENCES = "MyPrefs" ;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
How can I set the screen up so that it looks good in portrait as well as landscape mode?
Update code
<LinearLayout 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"
tools:context=".MainActivity"
android:background="#223399"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent">
<TextView
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:text="Login here"
android:gravity="center"
/>
<EditText
android:layout_marginTop="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<EditText
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<Button
android:layout_marginTop="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/loginClick"
android:layout_gravity="center"
/>
<TextView
android:layout_marginTop="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:text="New User?"
android:textColor="#00eeff"
android:gravity="center"
android:id="#+id/regiester_id"
/>
</ScrollView>
</LinearLayout>
I gave it a quick try using layout_weight. You can more fine tune it using different weights.
<LinearLayout 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"
tools:context=".MainActivity"
android:background="#223399"
android:orientation="vertical"
android:weightSum="5">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:text="Login here"
android:gravity="center"
android:layout_weight="1"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/loginClick"
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:text="New User?"
android:textColor="#00eeff"
android:gravity="center"
android:id="#+id/regiester_id"
android:layout_weight="1"
/>
</LinearLayout>
when i rotate my device it move to landscape .it is not showing button
and below text view ? can I add scroll view ? or can I add in %
percentage instead of dp.
I would say use ScrollView for better screen adjustment, it will be helpful in smaller device screens too.
also you can make different types of layouts for every size of screens and for landscape and portrait.
please refer to developer's site for types of screen layouts.
I hope you will get info for different types of screen size from there.
ScrollView must have only one child, try to change your code like that:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#223399">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceLarge"
android:text="Login here"
android:gravity="center"
/>
<EditText
android:layout_marginTop="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<EditText
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>
<Button
android:layout_marginTop="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/loginClick"
android:layout_gravity="center"
/>
<TextView
android:layout_marginTop="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:text="New User?"
android:textColor="#00eeff"
android:gravity="center"
android:id="#+id/regiester_id"
/>
</LinearLayout>
</ScrollView>
Scroll View Must have one child. So update your code with below and seee its working or not.
<ScrollView 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"
android:background="#223399"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Login here"
android:textAppearance="?android:textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="80dp"
android:hint="Username" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:hint="Password" />
<Button
android:id="#+id/loginClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="80dp"
android:text="Login" />
<TextView
android:id="#+id/regiester_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center"
android:text="New User?"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#00eeff" />
</LinearLayout>
</ScrollView>

Italic font changes TextView layout in Galaxy S5

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>

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)

Categories

Resources