1
 <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/layouts"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" >
      <ScrollView
    android:id="@+id/SCROLLER_ID"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
     >

    <LinearLayout
        android:id="@+id/images"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
           android:lineSpacingMultiplier="1.2"
            android:padding="12dp"

            />

        <TextView
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center"
            android:layout_weight="1"
            android:gravity="bottom|center" />
    </LinearLayout>
    </ScrollView>
   </RelativeLayout>

I am trying to set Gravity bottom for textview in view .But I surprized Gravity is not working.I can do this by writing params.setMargins(20,700,20,8); but this is not a good option for all types of device.

   This is my XML Layout:
  <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/layouts"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="horizontal" >


   <LinearLayout
    android:id="@+id/images"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

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

        <TextView
            android:id="@+id/text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
             />

        </ScrollView>

    <TextView
        android:id="@+id/footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="bottom" />
        </LinearLayout>
    </RelativeLayout>

   This is My ViewPagerAdapter class:

     public class ViewPagerAdapter extends PagerAdapter
        {


     public Object instantiateItem(ViewGroup container, int position) 
     {
     LinearLayout layouts;
     TextView countpages;
     inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     View itemview=inflater.inflate(R.layout.main_layout,container,false);

      layouts=(LinearLayout) itemview.findViewById(R.id.images);
      textview=(TextView) itemview.findViewById(R.id.text);
      countpages=(TextView) itemview.findViewById(R.id.footer);

         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams
         (new  LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
          params.gravity=Gravity.BOTTOM;    // This is not working
          textview.setLayoutParams(params);

      } 
Rims
  • 23
  • 5

2 Answers2

0

There is no need of ScrollView. You can directly make the text inside TextView scrollable. for reference check this link

Community
  • 1
  • 1
Ali
  • 1,857
  • 24
  • 25
0

No need forRelativeLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="#FFFF0000">
        <!-- scrollable contentn -->
    </ScrollView>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="some text"/>
</LinearLayout>

EDIT One more thing - always set your margins in your layout files rather than in classes.

aldorain
  • 790
  • 5
  • 16
  • I want to scroll both background linear layout image and content text over it simultanously except footer textview. – Rims Sep 12 '14 at 12:31