Naruto
Naruto

Reputation: 9634

How to add space between Textview and Tabbedview in android

I have got relative layout, in that i have placed two textviews, one image view & tabbed view. i have got tabbed view at bottom. I would like to add space between the tabview as well as the imageview. How to achieve it?.

Here is the source code

    <?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="wrap_content"
    android:padding="6dip">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="100dip"
        android:layout_height="100dip"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="6dip"
        android:scaleType="center"
        android:src="@drawable/ic_launcher"/>

    <TextView
                    android:text="Hello world"
                    android:id="@+id/serviceName" 
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" 
                    android:singleLine="true" 
                    android:focusable="true" 
                    android:focusableInTouchMode="true" 
                    android:freezesText="true"></TextView>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/icon"
        android:layout_alignLeft="@+id/serviceName"
        android:gravity="center_vertical"
        android:text="123456789"
        android:textSize="30dip" />

  <TabHost
    android:id="@android:id/tabhost"
    android:layout_below="@+id/icon"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TabWidget
            android:id="@android:id/tabs"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>

          <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0"/>

        <FrameLayout
            android:id="@+android:id/realtabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

    </LinearLayout>
</TabHost>

</RelativeLayout>

Upvotes: 0

Views: 2455

Answers (1)

RPB
RPB

Reputation: 16320

Try this

 <?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="wrap_content"
    android:padding="6dip">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="100dip"
        android:layout_height="100dip"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="6dip"
        android:scaleType="center"
        android:src="@drawable/ic_launcher"/>

    <TextView
                    android:text="Hello world"
                    android:id="@+id/serviceName" 
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" 
                    android:singleLine="true" 
                    android:focusable="true" 
                    android:focusableInTouchMode="true" 
                    android:freezesText="true"></TextView>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/icon"
        android:layout_alignLeft="@+id/serviceName"
        android:gravity="center_vertical"
        android:text="123456789"
        android:textSize="30dip" />

  <TabHost
    android:id="@android:id/tabhost"
    android:layout_below="@+id/icon"
    android:layout_marginLeft="6dip"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TabWidget
            android:id="@android:id/tabs"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>

          <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0"/>

        <FrameLayout
            android:id="@+android:id/realtabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

    </LinearLayout>
</TabHost>

Upvotes: 1

Related Questions