-2

In this code I need align the buttons a Textview to the left, I try everythnin , with relative layout, gravity etcc....

I dont now why this align still togehter to the center in horizontal line, I need to the left side!

<?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="@color/dark_background"
android:orientation="vertical"
 android:gravity="left" >

         <ScrollView android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<LinearLayout    
   android:gravity="left"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
 android:padding="6dip"  
 >
 <TextView  
    android:id="@+id/help_page_intro"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/help_page_intro"
    android:padding="2dip"
    android:layout_weight="1"
       />
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:padding="4dip"
    android:layout_gravity="left" 
    >
    <Button android:id="@+id/help_button1"
    android:layout_weight="1"
    android:layout_width="180dip"
    android:layout_height="wrap_content"
        style="@style/HelpButton.Dark"
        android:onClick="onClickHelp"
        android:text="@string/help_title_section1"
        android:drawableTop="@drawable/help_image1"/>
    <TextView  
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/help_text_section1"
    android:padding="8dip"
    android:layout_weight="1"
       />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
    <Button android:id="@+id/help_button2"
    android:layout_weight="1"
    android:layout_width="180dip"
    android:layout_height="wrap_content"
    android:gravity="left"
        style="@style/HelpButton.Dark"
        android:onClick="onClickHelp"
        android:text="@string/help_title_section2"
        android:drawableTop="@drawable/help_image2"/>
    <TextView  
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/help_text_section2"
    android:padding="8dip"
    android:layout_weight="1"
       />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_alignParentLeft="true">
    <Button android:id="@+id/help_button3"
    android:layout_weight="1"
    android:layout_width="180dip"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
        style="@style/HelpButton.Dark"
        android:onClick="onClickHelp"
        android:text="@string/help_title_section3"
        android:drawableTop="@drawable/help_image3"/>
    <TextView  
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/help_text_section3"
    android:padding="8dip"
    android:layout_weight="1"
       />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="left" >
    <Button android:id="@+id/help_button4"
    android:layout_weight="1"
    android:layout_alignParentLeft="true"
    android:layout_width="180dip"
    android:layout_height="wrap_content"
     android:gravity="left"
        style="@style/HelpButton.Dark"
        android:onClick="onClickHelp"
        android:text="@string/help_title_section4"
        android:drawableTop="@drawable/help_image4"/>
    <TextView  
       android:layout_width="wrap_content" 
        android:gravity="left"
       android:layout_height="wrap_content" 
       android:text="@string/help_text_section4"
    android:padding="8dip"
    android:layout_weight="1"
       />
</LinearLayout>

user2165656
  • 445
  • 1
  • 3
  • 11
  • do you want to align button to be on the left and textview on the right or viceversa? – Sanjeev Jul 17 '15 at 17:20
  • I tried using your XML. All your views are aligned to the left side properly. Please make your question clear...do you want your views to stick to the left side without leaving any space? – aashima Jul 17 '15 at 17:31
  • there is picture: help_button1, and next is the text.....there are aligned horizontal to the center by the text, but I need the help_button1 and texview align to the left side together! – user2165656 Jul 17 '15 at 17:45

1 Answers1

0

Sorry, not fully understanding. Did you want them lined up vertically? Then that would just be setting orientation to vertical in the linear layout. I looked at what this xml does right now. It appears to be button which is half the screen and textview with is the other half. Could you explain a little more what you want to see?

 <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="4dip"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:layout_height="wrap_content">

                <Button android:id="@+id/help_button1"
                        android:layout_weight="1"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:onClick="onClickHelp"/>
                <View
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_weight="1"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/help_page_intro"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/hello_world"
                    android:textColor="@color/black"
                    android:padding="2dip"
                    android:layout_weight="1"
                    />
                <View
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight="1"/>
            </LinearLayout>

        </LinearLayout>
Ashley Alvarado
  • 1,078
  • 10
  • 17
  • I want this button a and text view align to the left side (in each half part) – user2165656 Jul 17 '15 at 17:52
  • Still not sure if what I just added is what you mean. If not then a little image might be better of what you see and want. Because to the rest of us that is aligned to the left in the basic sense of it. – Ashley Alvarado Jul 17 '15 at 18:07