<?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"
android:background="#00b9e8"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView2"
android:layout_marginRight="32dp"
android:src="#drawable/backbutton" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#6AED83"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="122dp"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginLeft="14dp"
android:layout_marginTop="16dp"
android:background="#drawable/roundedlinearlayout3"
android:weightSum="4" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/user_s_icon" />
<EditText
android:id="#+id/editText1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4" >
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/layout1"
android:layout_below="#+id/layout1"
android:layout_marginTop="27dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</RelativeLayout>
This is my Xml i am Unable to set Linear layout inside text view and image button Like desire image:
This is my desire screen : below is my current screen :
i am unable to set text-view and image view on top of Linear layout
Try this way,hope this will help you to solve your problem.
Instead of using RelativeLayout use LinearLayout which can be easily done your requirement.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00b9e8"
android:orientation="vertical">
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/backbutton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="10dp"
android:background="#drawable/roundedlinearlayout3">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4"
android:drawableLeft="#drawable/user_s_icon">
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</LinearLayout>
<LinearLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#6AED83"
android:gravity="center"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
Related
Can anybody tell me why this ScrollView is not working? I checked the other answers for this question and it hasn't solved my problem. It has just one child. It has a closing bracket. Any ideas? Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<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="#89abe3"
tools:context=".GardaLoginActivity" >
<RelativeLayout
android:layout_width="match_parent" android:layout_height="match_parent"
android:focusableInTouchMode="true" android:fitsSystemWindows="true"
android:background="#89abe3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Smart Neighborhood Watch"
android:id="#+id/Logo"
android:textSize="40dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textColor="#ffdd00"
android:textStyle="bold"/>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<TextView
android:id="#+id/lblGardaEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Email"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp">
<EditText
android:id="#+id/txtGardaEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textEmailAddress"
android:textColor="#FFFFFF"/>
<requestFocus />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp">
<TextView
android:id="#+id/lblGardaPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/password"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp">
<EditText
android:id="#+id/txtGardaPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#cccccc"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:layout_centerHorizontal="true"
android:paddingTop="30dp"
android:gravity="center"
android:weightSum="1">
<Button
android:id="#+id/btnGardaLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login"
android:background="#66c2ff"
android:textColor="#FFFFFF"
android:layout_weight="0.30" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout5"
android:layout_centerHorizontal="true"
android:paddingTop="10dp"
android:gravity="center"
>
<TextView
android:id="#+id/textViewGardaRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Not a member? Register"
android:paddingTop="10dp"
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Sorry that i wrote this as an awnser as I can't comment on questions.
If your layout is bigger than your screen the scrollview will work.
And One more thing Child layout of ScrollView's height wrap_content
<?xml version="1.0" encoding="utf-8"?>
<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="#89abe3"
tools:context=".GardaLoginActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:fitsSystemWindows="true"
android:background="#89abe3">
//Your Code
</RelativeLayout>
</ScrollView>
just Change your child Relative layout to
<RelativeLayout
android:layout_width="match_parent" android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="#89abe3">
as the relative layouts android:fitsSystemWindows="true" attribute is using whole screen there is no room for ScrollView to scroll.
Important Note :
According to Android guidelines, android:layout_height attribute of
the first (and only) ScrollView children should always be
"wrap_content". You will get a Lint warning if you use match_parent
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
with this code:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<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="#89abe3"
tools:context=".GardaLoginActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#89abe3"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true" >
<TextView
android:id="#+id/Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="35dp"
android:gravity="center"
android:text="Smart Neighborhood Watch"
android:textColor="#ffdd00"
android:textSize="40dp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<TextView
android:id="#+id/lblGardaEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/txtGardaEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textEmailAddress"
android:textColor="#FFFFFF" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<TextView
android:id="#+id/lblGardaPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/txtGardaPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="30dp"
android:weightSum="1" >
<Button
android:id="#+id/btnGardaLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.30"
android:background="#66c2ff"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout5"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="10dp" >
<TextView
android:id="#+id/textViewGardaRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="Not a member? Register"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout6"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout7"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout8"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout9"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout10"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout11"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout12"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout13"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout14"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout15"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
android:textColorHint="#cccccc" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout16"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp" >
<EditText
android:id="#+id/edt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Minimum 7 characters"
android:inputType="textPassword"
android:textColor="#FFFFFF"
/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
I have checked your code. It's working perfectly even with scroll.
Do you have any other doubt?
Sorry for my english. I have background image, if keyboard show is resize background image. If keyboard not show evrithing work fine.
sorry obout image i have not 15 reputation
Its normal condition: image
Its if keyboard is show: image, background image is resize
Its if i in manifest i write adjustPan image
Bellow my xml:
<?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"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:background="#9a5f35"
android:layout_height="50dp" >
<LinearLayout
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="Получить бонус"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20sp" />
<RelativeLayout
android:id="#+id/backDd"
android:layout_width="100dp"
android:layout_height="50dp" >
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="#drawable/back_arraund" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:fadingEdge="none" >
<ImageView
android:id="#+id/imageView21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/bg_shkaf" />
</ScrollView>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="1) Введите сумму вашего счета"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="2) Сгенерируйте код"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="3) Покажите код официанту"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="4) Получите бонус на счет"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:gravity="center"
android:lineSpacingMultiplier="1.2"
android:text="Бонусы дают привликательную возможность\nполучть скидки и обменивать их на подарки\nот нашего кафе.Получайте как можно больше\nбонусов, для более ценных подарков"
android:textColor="#d2d3ce"
android:textSize="13dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:text="Введите сумму:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" >
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_radius_get_bonus"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/summgrn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:hint="1200"
android:inputType="number"
android:maxLines="1"
android:maxLength="5"
android:background="#null"
android:textColor="#fff"
android:textColorHint="#91623f" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:text="грн."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="1dp"
android:text="и покажите официанту код"
android:textColor="#fff"
/>
<ImageView
android:id="#+id/registrationsdasdad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:src="#drawable/review_button"
android:visibility="invisible" />
<TextView
android:id="#+id/textView102"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="50dp"
android:layout_marginTop="1dp"
android:text="Мы очень старались - оцените нас!"
android:textColor="#fff"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:id="#+id/imageView212"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:layout_marginTop="10dp"
android:visibility="invisible"
android:src="#drawable/image_8" />
<RelativeLayout
android:id="#+id/generateBonus"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#9a5f35"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Получить"
android:textColor="#fff"
android:textSize="20dp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
For my college I'm making an android app..
The xml code is:--
<?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"
android:background="#drawable/back">
<LinearLayout
android:id="#+id/linear_login"
android:layout_width="320dp"
android:layout_height="430dp"
android:background="#drawable/oie_transparent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="10dp"
android:text="College name"
android:textColor="#color/red1"
android:textSize="20dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="14dp"
android:padding="15dp"
android:text="#string/desc"
android:textColor="#color/purple2"
android:textSize="20dp" />
<LinearLayout
android:layout_width="230dp"
android:layout_height="180dp"
android:layout_marginLeft="40dp"
android:padding="10dp"
android:orientation="vertical" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:background="#drawable/edit_style"
android:ems="10"
android:hint="student name"
android:textColorHint="#7D0541"/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/edit_style"
android:layout_marginTop="6dp"
android:ems="10"
android:hint="student roll no"
android:textColorHint="#7D0541">
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Press Here"
android:layout_marginTop="8dp"
android:layout_gravity="center"
android:background="#drawable/button_state"
android:textColor="#0000A0"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_gravity="center"/>
</LinearLayout>
Here,the 2 edit boxes and one button is there,I want to add a scrollview in there..But When I am adding its showing error every time..Hey guys can anyone tell me where is the problem..
Paste your above line of code in between the scroll line of code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
//Paste your xml code here
</ScrollView>
try this,
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/btnEdit"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvExtraCharge"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/sackscontainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
</LinearLayout>
Are you looking for something like this.
<?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"
>
<LinearLayout
android:id="#+id/linear_login"
android:layout_width="320dp"
android:layout_height="430dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="10dp"
android:text="College name"
android:textColor="#android:color/darker_gray"
android:textSize="20dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="14dp"
android:padding="15dp"
android:text="description"
android:textColor="#android:color/white"
android:textSize="20dp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="230dp"
android:layout_height="180dp"
android:layout_marginLeft="40dp"
android:padding="10dp"
android:orientation="vertical" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:ems="10"
android:hint="student name"
android:textColorHint="#7D0541"/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:ems="10"
android:hint="student roll no"
android:textColorHint="#7D0541">
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Press Here"
android:layout_marginTop="8dp"
android:layout_gravity="center"
android:textColor="#0000A0"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_gravity="center"/>
</LinearLayout>
Use ScrollView as parent layout for linear_login and try to remove un-required inner LinearLayout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/back">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:id="#+id/linear_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/oie_transparent"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="College name"
android:textColor="#color/red1"
android:textSize="20dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:padding="15dp"
android:text="#string/desc"
android:textColor="#color/purple2"
android:textSize="20dp" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/edit_style"
android:ems="10"
android:hint="student name"
android:textColorHint="#7D0541"/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/edit_style"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="student roll no"
android:textColorHint="#7D0541"/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Press Here"
android:layout_marginTop="10dp"
android:background="#drawable/button_state"
android:textColor="#0000A0"/>
</LinearLayout>
</ScrollView>
<ImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher"/>
</LinearLayout>
I am trying to create a layout it was working good yesterday but today I am opened the xml view all the text of controls is right aligned it happen with every screen.
<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="#drawable/bg"
>
<RelativeLayout
android:id="#+id/layout_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_loginArea"
android:gravity="center_horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo" />
</RelativeLayout>
<LinearLayout
android:id="#+id/layout_loginArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="#+id/edit_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/txt_box"
android:hint="#string/usernamehint"
android:inputType="textPersonName"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="4dp"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<EditText
android:id="#+id/edit_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:background="#drawable/txt_box"
android:hint="#string/passwordhint"
android:inputType="textPassword"
android:padding="4dp"
android:paddingBottom="4dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="4dp"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<Button
android:id="#+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:background="#drawable/signin_button"
android:text="#string/loginButtonText" />
<TextView
android:id="#+id/txt_forgotpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/forgotpassword" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_createAccount"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<Button
android:id="#+id/button_facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/facebook_button"
android:text="#string/createaccount" />
<Button
android:id="#+id/button_createAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/create_account" />
</LinearLayout>
</RelativeLayout>
Set the width of view and make view gravity="center"
<LinearLayout
android:id="#+id/layout_createAccount"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:padding="10dp" >
<Button
android:id="#+id/button_facebook"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/app_bg"
android:gravity="center"
android:text="createaccount" />
<Button
android:id="#+id/button_createAccount"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#color/app_bg"
android:gravity="center"
android:text="createaccount" />
</LinearLayout>
I have made a simple application, with a background image, 4 image buttons and 4 text views in front of them.
I've read the google development documentation, but I still don't understand why in screens with a different size of 4,7" the app doesn't run normally. The textview is not in the right place. The image buttons are too small or too big in wrong places
I've created different images for differente resolutions (ldpi, mdpi, hdpi,xhdpi).
Here is the xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gameinterface"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".QuestionsActivity" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="95dp"
android:layout_marginRight="10dp"
android:layout_marginTop="137dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tvQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" >
<TextView
android:id="#+id/tvNumQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#B22222"
android:textSize="30sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/20"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#B22222"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout3"
android:layout_alignLeft="#+id/linearLayout4"
android:layout_marginBottom="114dp" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/btnR1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<ImageButton
android:id="#+id/btnR3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/btnR2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<ImageButton
android:id="#+id/btnR4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>