I am unable to see the top most views under ScrollView.
I had placed the scrollview under Relative layout. ScrollView has a child layout i.e. Linear layout which has some series of buttons.
Problem is that i am unable to see the top most views which are present in the ScrollView.
Below is the layout xml code.
<?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:background="#217d27"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:onClick="backPressed"
android:text="Back"
android:textColor="#000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:text="Heading Text"
android:textColor="#fff"
android:textSize="20sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:onClick="homeButtonClicked"
android:text="Home"
android:textColor="#000" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdge="none"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#fff"
android:orientation="vertical" >
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button 1"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 2"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 3"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 4"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 5"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 6"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 7"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 8"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 9"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 10"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 11"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 12"
android:textColor="#color/black" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Please see the screen shot for reference.
just remove this line in linear layout which is direct child of scroll view
android:layout_gravity="center" try this code which is updated
<?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:background="#217d27"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:onClick="backPressed"
android:text="Back"
android:textColor="#000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:text="Heading Text"
android:textColor="#fff"
android:textSize="20sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:onClick="homeButtonClicked"
android:text="Home"
android:textColor="#000" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdge="none"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical" >
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button 1"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 2"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 3"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 4"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 5"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 6"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 7"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 8"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 9"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 10"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 11"
android:textColor="#color/black" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Button 12"
android:textColor="#color/black" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Just change the LinearLayout inside the ScrollView
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:background="#fff"
android:orientation="vertical" >
Give the android:layout_gravity="top|center" instead of android:layout_gravity="center"
Hope it helps.
This values helped me solve a similar problem:
Set android:fillViewport="true" on the ScrollView
and use android:gravity instead of android:layout_gravity on the ScrollView child, in my case a LinearLayout with all weights cleared.
Try changing the parent layout to Linear. It might work. Don't know how and why, but for me it worked in a similar situation. Give it a try.
Give a top padding of 50dp
<LinearLayout
android:id="#+id/linearLayout"
android:paddingTop="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
use android:layout_gravity="center" in LinearLayout
it's work 100%
1. LinearLayout ->
2. ScrollView->
<androidx.appcompat.widget.LinearLayoutCompat
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:gravity="center"
tools:context=".sales.CustomerDetailListActivity">
<ScrollView
android:id="#+id/layoutCard"
app:layout_constraintTop_toBottomOf="#+id/subtitle_of_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:layout_marginLeft="4dp"
android:fillViewport="false"
android:fadingEdge="none">
</ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
Related
In my screen design, I have an Action Bar and Bottom Bar (which basically a Linearlayout). In mid of the screen, I have few textviews and 4-5 buttons. I want to add the scroll in the middle part of the screen. But it is not working.
My code is here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/toAddrdrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/fromAddrDrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/toAddrdrop"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/distanceToCoverDrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/fromAddrDrop"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/distanceToCoverDrop"
android:orientation="vertical">
<Button
android:id="#+id/drop_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Drop Confirm" />
<Button
android:id="#+id/sai_out_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Sai Out" />
<Button
android:id="#+id/customer_in_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer In" />
<Button
android:id="#+id/customer_out_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer Out" />
<Button
android:id="#+id/customer_new_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer new" />
<Button
android:id="#+id/customer_new_drop22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer new 22" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/buttombardrop"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:background="#33B5E5"
android:orientation="horizontal">
<Button
android:id="#+id/callButton_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:drawableTop="#android:drawable/ic_menu_call"
android:paddingTop="8dp"
android:text="Call"
android:textColor="#FFFFFF" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#ffffff" />
<Button
android:id="#+id/mapButton_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:drawableTop="#android:drawable/ic_menu_mapmode"
android:paddingTop="8dp"
android:text="Map"
android:textColor="#FFFFFF" />
</LinearLayout >
</RelativeLayout>
I have observed that, I am able to scroll a bit till 4 buttons. How can I fix the scrollview.
Please help!!
You should beware that RelativeLayout behaves unexpected many times. so you should use LinearLayout.
Just replace your code by
<?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:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/toAddrdrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/fromAddrDrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/toAddrdrop"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/distanceToCoverDrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/fromAddrDrop"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/distanceToCoverDrop"
android:orientation="vertical">
<Button
android:id="#+id/drop_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Drop Confirm" />
<Button
android:id="#+id/sai_out_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Sai Out" />
<Button
android:id="#+id/customer_in_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer In" />
<Button
android:id="#+id/customer_out_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer Out" />
<Button
android:id="#+id/customer_new_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer new" />
<Button
android:id="#+id/customer_new_drop22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/button_active"
android:text="Customer new 22" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/buttombardrop"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#33B5E5"
android:orientation="horizontal">
<Button
android:id="#+id/callButton_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:drawableTop="#android:drawable/ic_menu_call"
android:paddingTop="8dp"
android:text="Call"
android:textColor="#FFFFFF" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#ffffff" />
<Button
android:id="#+id/mapButton_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:drawableTop="#android:drawable/ic_menu_mapmode"
android:paddingTop="8dp"
android:text="Map"
android:textColor="#FFFFFF" />
</LinearLayout >
</LinearLayout>
Ok, after trying any solution I found I decided to put my code in here for help.
I get HTML from JSON and I place it in a TextView to show it.
This is it:
hoursTextView.setText(Html.fromHtml(hours));
hoursTextView.setVisibility(View.VISIBLE);
My problem is, that whenever the content above this TextView takes alot of height, I see only cutted top letters of this TextView and I can't scroll down!
This is my Layout XML:
<?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"
>
<ProgressBar
android:id="#+id/loadData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/coverImg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_marginBottom="5dp"
/>
<TextView
android:id="#+id/fbAbout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/coverImg"
android:gravity="center"
/>
<View
android:id="#+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#eeeeee"
android:layout_below="#+id/fbAbout"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/seperator"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
>
<TextView
android:id="#+id/type"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/beer"
android:drawablePadding="5dp"
android:text="TYPE"
android:layout_weight="1"
/>
<TextView
android:id="#+id/age"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/age_big"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="AGE"
android:layout_weight="1"
/>
<Button
android:id="#+id/callToPlace"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/ic_call_black_24dp"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="CALL"
android:layout_weight="1"
/>
<Button
android:id="#+id/nav"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/navigate"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="navigate"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="HOURS"
android:id="#+id/hoursTitle"
android:layout_below="#+id/buttons"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:layout_marginTop="10dp"
/>
<!--This is the TextView which is cut -->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</RelativeLayout>
The last TextView, with the ID of hours, is being cut on the bottom of the screen.
Hope someone can help me with this,
thanks!
You can use ScrollView for full screen.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/output">
<ProgressBar
android:id="#+id/loadData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/coverImg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_marginBottom="5dp"
/>
<TextView
android:id="#+id/fbAbout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/coverImg"
android:gravity="center"
/>
<View
android:id="#+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#eeeeee"
android:layout_below="#+id/fbAbout"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/seperator"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
>
<TextView
android:id="#+id/type"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/beer"
android:drawablePadding="5dp"
android:text="TYPE"
android:layout_weight="1"
/>
<TextView
android:id="#+id/age"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/age_big"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="AGE"
android:layout_weight="1"
/>
<Button
android:id="#+id/callToPlace"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/ic_call_black_24dp"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="CALL"
android:layout_weight="1"
/>
<Button
android:id="#+id/nav"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/navigate"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="navigate"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="HOURS"
android:id="#+id/hoursTitle"
android:layout_below="#+id/buttons"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:layout_marginTop="10dp"
/>
<!--This is the TextView which is cut -->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</ScrollView>
Another Example:
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 3" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 4" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 5" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton 1" />
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton 2" />
<ToggleButton
android:id="#+id/toggleButton1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ToggleButton" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 6" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 7" />
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 8" />
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 9" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 10" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 11" />
</LinearLayout>
</ScrollView>
Add the scroll view
<ScrollView
android:layout_width="match_parent"
android:layout_height="150dp" >
<!--Just assume it whatever your height is-->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</ScrollView>
This question already has answers here:
How do you make a LinearLayout scrollable?
(10 answers)
Closed 3 months ago.
I am having a popup view in an android app. For the portrait screen the popup page showing properly, but if i rotate the screen to landscape the popup layout display partially. I have click buttons in the popup. Can't view the buttons in landscape mode. The popup page i am using is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
How can i display the full page in the screen in landscape or for small screens? Any help would be appreciated. Thanks in advance.
Check This I used your xml(change your background):-
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/ic_launcher"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Try this as you know ScrollView can have only one child so you put the ScrollView as parent Layout and then One child will be the linearlayout and then that will work. Try like this:
<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:fillViewport="true">
<LinearLayout
android:id="#+id/popup_element"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
But it is better that you use RelativeLayout instead of using so many linearlayouts. Hope it helps.
A ScrollView is a FrameLayout, meaning you must place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.
So you have to solve your problem with concept clearing you can follow my answer of this question. may it will clear your concept and help to solve your problem.
you can only take single tag(Child Layout) in scrollview. if you have put multiple Linear Layout then take single linearlayout and then put other Linear Layout in this.
I currently work on a quiz app. There is a question and four possible answer options. Each answer options is represented by a button. The four buttons are aligned in a rectangle.
Problem: If the button caption is too long, the button position slightly changes NS the button slips downward.
Question: Is there is a solution for this problem? I dont want the button to change its position.
XML Code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background" >
<TextView
android:id="#+id/tv_voc_trainer_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="44dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="This is my title!"
android:textSize="20sp" />
<LinearLayout
android:id="#+id/ll_voc_trainer_first_answer_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_voc_trainer_question"
android:layout_marginTop="40dp"
android:orientation="horizontal" >
<Button
android:id="#+id/bu_first_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:text="Answer 1" />
<Button
android:id="#+id/bu_second_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:text="Answer 2 is very long!" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_voc_trainer_second_answer_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ll_voc_trainer_first_answer_row"
android:orientation="horizontal" >
<Button
android:id="#+id/bu_third_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:text="Answer 3" />
<Button
android:id="#+id/bu_fourth_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:text="Answer 4" />
</LinearLayout>
<ImageView
android:id="#+id/img_trainer_answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ll_voc_trainer_second_answer_row"
android:layout_marginTop="25dp"
android:layout_centerHorizontal="true"
android:contentDescription="answer" />
</RelativeLayout>
This screenshot illustrates the problem. Button 2 has a longer caption and therefore his position automatically changed.
Try using this in your linear layout:
android:baselineAligned="false"
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/tv_voc_trainer_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="This is my title!"
android:textSize="20sp" />
<LinearLayout
android:id="#+id/ll_voc_trainer_first_answer_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center">
<Button
android:id="#+id/bu_first_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:gravity="center"
android:text="Answer 1" />
<Button
android:id="#+id/bu_second_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:gravity="center"
android:text="Answer 2 is very long!" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_voc_trainer_second_answer_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:gravity="center">
<Button
android:id="#+id/bu_third_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:gravity="center"
android:text="Answer 3" />
<Button
android:id="#+id/bu_fourth_answer_possibility"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:gravity="center"
android:text="Answer 4" />
</LinearLayout>
<ImageView
android:id="#+id/img_trainer_answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:contentDescription="answer" />
</LinearLayout>
I am using the following XML code for tablets in API Level 17.
<?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:layout_gravity="center" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:padding="40dp" >
<EditText
android:id="#+id/etUsername"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" >
</EditText>
<TextView
android:id="#+id/tvUsername"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:padding="40dp" >
<EditText
android:id="#+id/etPassword"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="#+id/tvPassword"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Password" />
</LinearLayout>
<Button
android:id="#+id/submitbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/buttonpressing"
android:text="Submit"
/>
<TextView
android:id="#+id/showresult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center" />
I want my TextView, EditText and Button to be centered. In landscape view (horizontal) they seem to be centred but in portrait(vertical) screen, they are in centre at the top of the screen.
How am I gonna fix it that no matter which view is this, they all stay in centre of screen?
Problem is that you set height of the root layout to "match_parent"
<?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="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:padding="40dp">
<EditText
android:id="#+id/etUsername"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text"></EditText>
<TextView
android:id="#+id/tvUsername"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:padding="40dp">
<EditText
android:id="#+id/etPassword"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="#+id/tvPassword"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Password" />
</LinearLayout>
<Button
android:id="#+id/submitbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit"
/>
<TextView
android:id="#+id/showresult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center" />
</LinearLayout>