I need set a textview (with its background) that fill half screen of device with fixed size of background. I try this code but I can't. The goal is: half screen, up I show image, down a textview.
<?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="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/luna"
android:textSize="15pt" />
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#000000" >
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="320dp"
android:background="#000000"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="14sp"
android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl"
android:autoLink="web|email"
android:textStyle="italic" />
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chiudi" />
</LinearLayout>
you can achieve this by adding weights.
<?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="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/luna"
android:textSize="15pt"
android:layout_weight="1"/>
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#000000"
android:layout_weight="1" >
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="320dp"
android:background="#000000"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="14sp"
android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl"
android:autoLink="web|email"
android:textStyle="italic" />
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chiudi" />
</LinearLayout>
Check this:
I have changed the inner linear layout to relative layout. I think it will give result as you want:
<?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="#000000"
android:orientation="vertical" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:background="#000000" >
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="320dp"
android:autoLink="web|email"
android:background="#000000"
android:gravity="center"
android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl"
android:textColor="#ffffff"
android:textSize="14sp"
android:textStyle="italic" />
</ScrollView>
<ImageView
android:id="#+id/img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/scrollView10"
android:background="#drawable/luna"
android:textSize="15pt" />
</RelativeLayout>
<Button
android:id="#+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chiudi" />
</LinearLayout>
I have defined scrollview first. And then I defined ImageView with match_parent sizes. So it takes up all remaining space of screen. This way, image proportion will also be proper. Hope it helps.
Related
I have a problem in my xml, the ScrollView does not work when my RelativeLayout is wrap_content, but if I have a larger screen than the fixed height works correctly, but if I have a larger fixed height than screen the works correctly, but I need to be wrap_content, because I have a listview that is populated gradually as client wants, follows the xml
<?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="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#fff">
</LinearLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="45"
android:fillViewport="true"
android:scrollbars="vertical">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|center_horizontal"
android:id="#+id/lb_cabec"
android:text="#string/str_cabec" />
<TextView
android:id="#+id/lb_pessoa_status"
android:paddingTop="4dp"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textStyle="bold"
android:text="#string/pessoas_lb_mesa_cartao"
android:layout_below="#+id/lb_cabec"/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_prod"
android:layout_below="#+id/lb_pessoa_status">
<TextView
android:layout_width="fill_parent"
android:id="#+id/lb_prodMistAdd_cabec_prod"
android:layout_height="wrap_content"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_prod" />
<ListView
android:id="#+id/mListProdMistAdd_prod"
android:layout_width="fill_parent"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
android:layout_below="#+id/lb_prodMistAdd_cabec_prod" />
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="#+id/mListProdMistAdd_prod"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_addProd"
android:text="#string/prodMistAdd_bt_prod" />
</RelativeLayout>
<LinearLayout
android:layout_height="10dp"
android:layout_width="fill_parent"
android:id="#+id/lb_espaco_1"
android:layout_below="#+id/relative_prod"
android:orientation="vertical">
</LinearLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_quant"
android:layout_below="#+id/lb_espaco_1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/lb_prodMistAdd_cabec_quant"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_quant" />
<LinearLayout
android:layout_height="5dp"
android:id="#+id/tab_espaco_2"
android:layout_below="#+id/lb_prodMistAdd_cabec_quant"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#fff">
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/tab_espaco_2"
android:orientation="horizontal">
<EditText
android:id="#+id/tb_prodMistAdd_quantidade"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:editable="false"
android:gravity="center_vertical|right"
android:ems="10"
android:inputType="textPersonName" />
<Button
android:layout_width="40dp"
android:layout_height="35dp"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_mais"
android:text="#string/prodMistAdd_bt_mais" />
<Button
android:layout_width="40dp"
android:layout_height="35dp"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_menos"
android:text="#string/prodMistAdd_bt_menos" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_height="10dp"
android:layout_width="fill_parent"
android:id="#+id/lb_espaco_2"
android:orientation="vertical"
android:layout_below="#+id/relative_quant">
</LinearLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_obs"
android:layout_below="#+id/lb_espaco_2">
<TextView
android:layout_width="fill_parent"
android:id="#+id/lb_prodMistAdd_cabec_obs"
android:layout_height="wrap_content"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_obs" />
<LinearLayout
android:layout_height="5dp"
android:id="#+id/tab_espaco_3"
android:layout_below="#+id/lb_prodMistAdd_cabec_obs"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#fff">
</LinearLayout>
<ListView
android:id="#+id/mListProdMistAdd_obs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_below="#+id/tab_espaco_3" />
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="#+id/mListProdMistAdd_obs"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:id="#+id/bt_log_voltar"
android:text="#string/prodMistAdd_bt_obs" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
My listview are configured to not scroll, through code
try do define ScrollView layout_width and layout_height as match_parent, without layout_weight
by the way, you should not mix ScrollView with ListView since both have his own scroll. I suggest to split it like:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
(...)
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
I'm trying to emulate a dock for a launcher with 3 text views evenly spaced out across said dock... For some reason I can't get my text views to center align with in there parent linear layouts, can someone please explain to me what is my issue here?
Here is my layout in XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<LinearLayout
android:id="#+id/footer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:paddingBottom="20dp"
android:paddingTop="20dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Internet Browser"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Flight Tracker"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Airline Info"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this out, I think you have too many inner layouts.. you can use layout_weight to achieve this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/blue"
android:orientation="horizontal"
android:padding="20dp"
android:weightSum="15.0" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Internet Browser"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Flight Tracker"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Airline Info"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I am creating an intro activity and What I want is that logo was double bigger than text, and the text was centered to the layout.
With the next code I am having problems with diferents layouts (in some screens the TextView is not shown:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/iconok" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
</LinearLayout>
What I am doing wrong?
As per your question and comments, I think below snippet will help you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="66"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/email_textview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="left|center"
android:layout_weight="33"
android:text="#string/app_name"
android:textSize="55sp" />
</LinearLayout>
(After your comment) then you should set first inner linear layout's weight 2, and second's 1. Also use layout_height =" 0" for them.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/iconok" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
test this code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.66" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.34" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
</LinearLayout>
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:weightSum="3"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#stringimage_view_desc"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="#drawable/image_view_desc" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#stringloading_text3" />
</LinearLayout>
</LinearLayout>
Try this and change margin according to your requirement.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="3" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:contentDescription=""
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="abcd"
android:textSize="55sp" />
</LinearLayout>
I need set textView10 at center of vertical and horizontal. I've tried a lot without results... I tried with gravity options but nothing.. any idea? textView10 is within scrollview. Thanks for help.
<?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="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="151dp"
android:layout_height="fill_parent"
android:textSize="15pt" />
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000" >
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:gravity="center_vertical"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="13sp"
android:textStyle="italic" />
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chiudi" />
</LinearLayout>
<?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="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="151dp"
android:layout_height="fill_parent"
android:textSize="15pt" />
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#000000" >
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="320dp"
android:background="#000000"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="13sp"
android:text="Hi What is your name"
android:textStyle="italic" />
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chiudi" />
Change your outer layout to RelativeLayout and position yout ScrollView at the parent center. Position other elements in relation to one in center
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView1"
android:layout_width="151dp"
android:layout_height="fill_parent"
android:textSize="15pt" />
<ScrollView
android:id="#+id/scrollView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#000000" >
<TextView
android:id="#+id/textView10"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:gravity="center_vertical"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="13sp"
android:textStyle="italic" />
</ScrollView>
</RelativeLayout>
Put the TextView inside of a RelativeLayout, and put that RelativeLayout inside of the ScrollView.
Then, set android:layout_centerInParent="true" within the TextView
I find majority teaching online is about 2 button beside each other but I couldnt obtain the arrangement wanted as in the image. When I put in the relativelayout, all the button overlap together no matter I put android:layout_above:"XX" All my total, 0.00, back and pay button , i need to out them at the bottom. this is my original 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:orientation="vertical" >
<TextView
android:id="#+id/billTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="#+id/backB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back" />
<Button
android:id="#+id/payB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pay" />
</LinearLayout>
<?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" >
<TextView
android:id="#+id/billTV"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text="TextView" />
<TextView
android:id="#+id/total"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="#+id/backB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back" />
<Button
android:id="#+id/payB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pay" />
</LinearLayout>
</LinearLayout>
Try some thing 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/billTV"
android:layout_width="fill_parent"
android:layout_height="394dp"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/total"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/backB"
android:layout_width="106dp"
android:layout_height="wrap_content"
android:text="Back" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical" >
<Button
android:id="#+id/payB"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Pay" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
try this