This is my first android application, I face a bunch of problems. I want to make a design like in this image:
I tried many solutions to do it, but nothing work.
This is my code:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View
android:layout_height="2dip"
android:background="#color/dark_blue"/>
<!--Product information-->
<TableRow android:id="#+id/product_info">
<ImageView android:id="#+id/product_img"
android:src="#drawable/mdpi_product_verify_scan_code"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView android:id="#+id/tvdesc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:text="description description description "
android:textColor="#color/black"
/>
</TableRow>
<View
android:layout_height="2dip"
android:background="#color/dark_blue"/>
<!--Images button-->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Product Description"
android:textColor="#color/black"
android:textAppearance="?android:textAppearanceMedium"
/>
<FrameLayout
android:background="#color/dark_blue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:padding="5dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/mdpi_btn_show_images_icon"
android:background="#android:color/transparent"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Images"/>
</FrameLayout>
</TableRow>
<TableRow android:id="#+id/product_info">
<ImageView android:id="#+id/ima"
android:src="#drawable/mdpi_product_verify_scan_code"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView android:id="#+id/tv2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:text="description description description "
android:textColor="#color/black"
/>
</TableRow>
<!--Verification -->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="product verification"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/green"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This product can be verified. Tap on the VERIFY PRODUCT button above."
android:textColor="#color/green"/>
</TableRow>
</TableLayout>
and this the result
as you can see, all the elements are messed up
and the images button disappear also when i set the gravity left the images disappear and the text stay where they are, nothing change.
This image shows what are the problems:
How to make each text on a row.
Set the image at the left (the gravity left didn't work)
How to draw a vertical line?
How can i put image with the text?( i was using the span but it's work just for one row here i have two text rows, is there anyway to merge two vertical cells).
The images button disappear.
Thanks for any help.
I guess this should help you a bit understand how it works. I manage to do something that looks like what you might need
<?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" >
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tap to Verify Product" />
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="16dp"
android:src="#drawable/ic_launcher" />
<View
android:id="#+id/view1"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:layout_toRightOf="#+id/imageView1"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignLeft="#+id/textView2"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView3"
android:layout_alignLeft="#+id/textView1"
android:text="TextView" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_marginLeft="21dp"
android:layout_toRightOf="#+id/view1"
android:text="TextView" />
</RelativeLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="46dp" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView" />
</LinearLayout>
Try it out in your IDE and from that, if you need further helps, I'll see what I can do.
Related
I have an xml which uses linear layout and weights to equally distribute space on the screen to a few buttons and such. When I rotate screen to landscape mode, the buttons all get compressed. Could someone tell me how to make the buttons take equal space, non scrollable, when in portrait, and the whole screen scrollable when in landscape. Presently I am not using any scrollview and the layout is looking good, with the table and buttons taking the right amount of space, but when i rotate the screen to landscape, everything gets compressed. I tried enclosing the Linear Layout inside a scrollview but that caused the Linear Layout to move out of the screen, so when in portrait mode, i have to scroll to see whole content. Here is my xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/linear"
android:orientation="vertical"
android:background="#bf000000"
tools:context=".MainActivity"
android:layout_above="#+id/imageView">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtReceive1"
android:visibility="gone"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/table"
android:background="#fff3f3f2"
android:stretchColumns="*"
android:shrinkColumns="*"
>
<TableRow>
<TextView
android:text="CH"
android:gravity="center"
android:padding="8dip"
android:layout_width="wrap_content" />
<TextView
android:text="kWh"
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content" />
<TextView
android:text="Load"
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content" />
<TextView
android:text="Date"
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content" />
</TableRow>
<TableRow >
<TextView
android:padding="8dip" android:layout_width="wrap_content"
android:gravity="center"
android:id="#+id/t11"
android:text="1" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t12" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t13" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t14" />
</TableRow>
<TableRow>
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t21"
android:text="2" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t22" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t23" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t24" />
</TableRow>
<TableRow>
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t31"
android:text="3" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t32" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content" />
<TextView
android:gravity="center"
android:padding="8dip"
android:layout_width="wrap_content"
android:id="#+id/t34" />
</TableRow> <TableRow>
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t41"
android:text="4" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t42" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t43" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t44" />
</TableRow>
<TableRow >
<TextView
android:padding="8dip" android:layout_width="wrap_content"
android:gravity="center"
android:id="#+id/t51"
android:text="5" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t52" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t53" />
<TextView
android:gravity="center"
android:padding="8dip" android:layout_width="wrap_content"
android:id="#+id/t54" />
</TableRow>
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff8c00"
android:padding="6dip"
android:id="#+id/txtReceive"
android:layout_below="#+id/table"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/lin2"
android:visibility="visible"
android:paddingTop="5dp"
android:weightSum="2">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:visibility="visible"
android:weightSum="4"
android:id="#+id/rel">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="fill_parent"
android:id="#+id/imageButton1"
android:layout_width="fill_parent"
android:background="#drawable/btn_01_small"
android:textColor="#ffa5ff45"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Channel"
android:textSize="22sp"
android:id="#+id/textView3"
android:layout_alignTop="#+id/imageButton1"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#ffa5ff45"
android:id="#+id/textView9"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton1"
android:layout_centerHorizontal="true" />
</RelativeLayout><RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/imageButton2"
android:background="#drawable/btn_02"
android:textColor="#ffa5ff45"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="kWh"
android:textSize="22sp"
android:id="#+id/textView6"
android:layout_alignTop="#+id/imageButton2"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="000.0"
android:textColor="#ffa5ff45"
android:id="#+id/textView10"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton2"
android:layout_centerHorizontal="true" />
</RelativeLayout><RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/imageButton3"
android:background="#drawable/btn_03"
android:textColor="#ffa5ff45"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Load"
android:id="#+id/textView7"
android:textSize="22sp"
android:layout_alignTop="#+id/imageButton3"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="000"
android:textColor="#ffa5ff45"
android:id="#+id/textView11"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton3"
android:layout_centerHorizontal="true" />
</RelativeLayout><RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/imageButton4"
android:background="#drawable/btn_04_small" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Days"
android:id="#+id/textView8"
android:textSize="22sp"
android:layout_alignTop="#+id/imageButton4"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="000"
android:textColor="#ffa5ff45"
android:id="#+id/textView12"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton4"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_alignParentRight="true"
android:visibility="visible"
android:weightSum="4"
android:layout_below="#+id/txtReceive"
android:id="#+id/rel2">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="fill_parent"
android:id="#+id/imageButton12"
android:layout_width="fill_parent"
android:background="#drawable/btn_01_small"
android:textColor="#ffa5ff45"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auto ON"
android:id="#+id/textView32"
android:textSize="22sp"
android:layout_alignTop="#+id/imageButton12"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00"
android:textColor="#ffa5ff45"
android:id="#+id/textView92"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton12"
android:layout_centerHorizontal="true" />
</RelativeLayout><RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/imageButton22"
android:background="#drawable/btn_04_small"
android:textColor="#ffa5ff45"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auto OFF"
android:textSize="22sp"
android:id="#+id/textView62"
android:layout_alignTop="#+id/imageButton22"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00"
android:textColor="#ffa5ff45"
android:id="#+id/textView102"
android:textSize="22sp"
android:layout_alignBottom="#+id/imageButton22"
android:layout_centerHorizontal="true" />
</RelativeLayout><RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/imageButton31"
android:layout_marginTop="7dp"
android:layout_marginBottom="-14dp"
android:background="#drawable/send_btn_01"
android:textSize="22sp"
android:text="SET TIME" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="matrix"
android:layout_marginBottom="-7dp"
android:id="#+id/imageButton32"
android:padding="0dp"
android:background="#drawable/send_btn_01"
android:textSize="22sp"
android:text="RECHARGE" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/base_irya_left1"
android:background="#bf000000"
android:adjustViewBounds="true"
android:layout_alignParentBottom="true" />
<!-- </RelativeLayout> -->
Did you consider using Fragments in Android. Here is a tutorial.
How to support different screensizes with fragments(See here)
It is possible to define in the layout file of an activity that it contains fragments (static definition) or to modify the fragments of an activity at runtime (dynamic definition).
To display differnet fragments in your activities based on the actual available space you can:
Use one activity, which displays two fragments for tablets and on handset devices. In this case change at runtime the fragments displayed by the activity whenever necessary. In this scenario you typically define instances of the FrameLayout class as placeholder in your layout and add the fragments at runtime to them.
Use separate activities to host each fragment on a handset. For example, when the tablet UI uses two fragments in an activity, use the same activity for handsets, but supply an alternative layout that includes just one fragment. If the detailed fragment is there, the main activity tells the fragment that it should update itself. If the detail fragment is not available, the main activity starts the detailed activity.
Which option to select depends on the use case, typical the dynamic contribution is more flexible bit a bit harder to implement.
Creating two xmls, one for landscape and one for portrait, will fix the issue. Portrait goes into res/layout folder and landscape goes into res/layout-land. The two should have identical names for this to work.
I am trying to create a Row layout to use in my ListView,
but when the text is too long, it pushes the right hand side ImageButton off the screen.
I want the text to just continue on the next line without interfering with the ImageButton-
This is the layout I have so far, I tried adding weight properties to set how much space could be use but I couldn't get it to work.
<?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="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/Text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/ImageButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawableTop="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Thank You.
No matter what lenght if text, first and last image will be of width 50dp occupied, rest space for text.
<LinearLayout
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/Text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/ImageButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawableTop="#drawable/ic_launcher" />
</LinearLayout>
You're using too many LinearLayouts, and also you're not defining any constrain for your views space.
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="fill_parent" >
<ImageView
android:id="#+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="#drawable/ic_launcher" />
<ImageButton
android:id="#+id/ImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:drawableTop="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/ImageButton"
android:layout_toRightOf="#id/ImageView"
android:orientation="vertical" >
<TextView
android:id="#+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/Text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</RelativeLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="I like to go out more than staying home."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="Do you tend to over analyze everything, all the time?"
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="You've made most of your decisions based on how you feel."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="You use past experiences to guide your decisions."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
</ScrollView>
<Button
android:id="#+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" />
<TextView
android:id="#+id/personalitytype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Personality Type"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</TableLayout>
A picture of my applicaton can viewed here : http://tinypic.com/r/2uy1t3d/5
Hello, I'd like to add a scroll view to my questions in my application. This would include the TextViews and Spinners but not the Submit button on the bottom or the TextView below it. I understand you'd have to mess with the weight, but i'm not getting good results. Thanks
If you want the Button and TextViews below it to remain at the bottom, try putting everything in a RelativeLayout, wrapping your Buttons and TextViews in a LinearLayout and aligning it to the parent's bottom.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="I like to go out more than staying home."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="Do you tend to over analyze everything, all the time?"
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="You've made most of your decisions based on how you feel."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="You use past experiences to guide your decisions."
android:textSize="10.5dp" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" />
<TextView
android:id="#+id/personalitytype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Personality Type"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</RelativeLayout>
Full disclaimer: Code not tested.
I'm having issues with Android 4.3 (EDIT: IN ALL APIS) in a RelativeLayout with a TableLayout header, a LinearLayout scrollable body and a LinearLayout footer.
The body contains two webviews and the activity works perfectly with API level <18. When I run my application in API level 18 (either simulated by AVD or installed in my Galaxy Nexus), when the webViews load the content, the text of textViews in the TableLayout disappear, and only remain the first Character (or the first two charachters if the text is in two lines). It seems the webView change the orientation of the text..
I tried to insert android:orientation="horizontal" in the TableLayout and in the TableRow, but without results. Only if i remove my webViews, the text will be show
Is it an Android 4.3 bug, or i have to insert something in my code?
I attached my xml file and a link to the screenshot.
----> Image
XML 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="match_parent" >
<!-- parte superiore (tabs) -->
<TableLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="2dp">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/dati_imp"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_margin="0dp"
android:layout_weight="0.335"
android:background="#669900"
android:gravity="center"
android:text="#string/dati_imp"
android:textColor="#color/White" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/inverter"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.335"
android:gravity="center"
android:text="#string/inverter" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/cfr_inv"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.33"
android:gravity="center"
android:text="#string/cfr_inv" />
</TableRow>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/cont_fisc"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:gravity="center"
android:text="#string/cont_fisc" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/contatti"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:gravity="center"
android:text="#string/contatti" />
</TableRow>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</TableLayout>
<!-- parte inferiore (button) -->
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingTop="2dp" >
<Button
android:id="#+id/refresh_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dip"
android:text="#string/refresh_button_label" />
</LinearLayout>
<!-- parte centrale -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/footer"
android:layout_below="#id/header" >
<LinearLayout
android:id="#+id/body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/cornice1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/dati_gen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:gravity="center"
android:padding="6dp"
android:text="#string/dati_imp"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<TextView
android:id="#+id/kwn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/dataAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/tariffa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/co2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/conto_en"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/conto_en"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<TextView
android:id="#+id/oggiEn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/meseEn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/annoEn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/totEn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:padding="8dp"
android:text="#string/conto_en_txt"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/foto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/foto"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<WebView
android:id="#+id/webview_foto"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/pot_imp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/pot_imp"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="70dp" >
<ProgressBar
android:id="#+id/potPerc"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:max="100"
android:progressDrawable="#drawable/progressbarpotenza" />
<TextView
android:id="#+id/potTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/potPerc"
android:layout_centerInParent="true"
android:textColor="#android:color/black" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/cornice5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/stato_imp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/stato_imp"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<ImageView
android:id="#+id/fotostato"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="6dp" />
<TextView
android:id="#+id/nonatt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/pot_tot"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/pot_tot"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<TextView
android:id="#+id/potenza"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/maxgiorno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/maxmese"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/maxanno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical" >
<TextView
android:id="#+id/prod_tot"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/prod_tot"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<TextView
android:id="#+id/oggi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/mese"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/anno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/tot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/prod_tot_k"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/prod_tot_k"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="#+id/oggiKWp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/meseKWp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/annoKWp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:padding="4dp" />
<TextView
android:id="#+id/totKWp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="2dp"
android:padding="4dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cornice8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#drawable/cornice"
android:orientation="vertical"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/meteo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="6dp"
android:text="#string/meteo"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/Gray" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp" >
<WebView
android:id="#+id/webview_meteo"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
<TextView
android:id="#+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingTop="6dp"
android:text="#string/info"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
EDIT:
I verified that the orientation of textView change (inserting android:layout_height="300dp" in the TableLayout's textViews to see the entire text). Now, how to fix it??
EDIT2:
In another activity with a layout that contents an ExpandableListview, i have exactly the same problem, and the group indicator, positioned by the code to right, go to the left side of each group item. I repeat, this only in API 18...
EDIT3: SOLVED
I finally got the solution and attached as new answer! (title changed)
Finally, after going crazy to understand where the problem was, i got the solution!!
I don't know why, but i discovered i had the same issue in all activities that show a TableLayout and 0px width and a weight childs attribute.
Changing something in UI, like loading the WebView(s), or (in another activity), resume activity after a spinner selection, caused the problem.
In the second case i had trouble also in API < 18 (virtual and real) devices, then i realize it was not only an API 18 bug...
I solved my issue only adding a TableLayout attribute in each XML file with the specified TableLayout:
android:stretchColumns="*"
After adding that in all my TableLayouts, i solved it!
Hope this help =)..
I have a LinearLayout in one of the activities as the main layout. I used Scrollview to encapsulated the LinearLayout. The Layout contains a fragment which displays a google map, but on scrolling it gave black background. I resolved the issue by using a transparent background inside a FrameLayout. The black background has gone, but during scrolling i get flickering black edges around the map. How to remove this? I tried setting the background of Scrollview to white color, but no change visible.
The XML of the activity is --
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:baselineAligned="false"
android:orientation="vertical"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:showDividers="none" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ec4d1d" >
<TextView
android:id="#+id/friend_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="7dp"
android:background="#drawable/near_you_bg"
android:gravity="center_horizontal|center_vertical"
android:padding="6dp"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
<Button
android:id="#+id/btnInviteFriends"
android:layout_width="30dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="7dp"
android:background="#drawable/menu_bg"
android:onClick="inviteFriends" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="81dp"
android:background="#drawable/list_bg"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="4dp"
android:gravity="center_vertical|center_horizontal" >
<RelativeLayout
android:layout_width="65dp"
android:layout_height="70dp" >
<ImageView
android:id="#+id/user_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="7dp"
android:src="#drawable/d_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="140dp"
android:layout_height="70dp" >
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_toRightOf="#id/user_image"
android:paddingBottom="2dip"
android:text="Amrinder"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/distance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_marginTop="2dp"
android:layout_toRightOf="#id/user_image"
android:text="description"
android:textColor="#000000"
android:textSize="10sp" >
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/distance"
android:layout_marginTop="7dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/common_icon"
android:layout_width="26dp"
android:layout_height="19dp"
android:background="#drawable/common_icon" />
<TextView
android:id="#+id/common_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="4"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:id="#+id/friends_icon"
android:layout_width="26dp"
android:layout_height="19dp"
android:layout_marginLeft="7dp"
android:background="#drawable/friends_icon" />
<TextView
android:id="#+id/friends_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="5"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/nearUserInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/time_ago"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 min ago"
/>
<ImageView
android:id="#+id/dir_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time_ago"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:background="#drawable/say_hi_button" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
<ImageView
android:id="#+id/map_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_centerInParent="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp" >
<TextView
android:id="#+id/distance_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:text="X is 4 km north-east of you now"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_below="#id/map_bar"
/>
<View
android:id="#+id/trans_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/trans" />
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/like_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp" >
<ImageView
android:id="#+id/like_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_detail_icon" />
<TextView
android:id="#+id/likes_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/like_button"
android:gravity="center_vertical"
android:text=" 3 likes in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/like_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/like_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Instead of using a transparent image above the map fragment you try using the transparent color becauz i was also facing the same issue and i solved using this method.
android:background="#android:color/transparent"
But technically speaking as suggested by Android you should not use a scrolling element inside another scrolling element.Rather you can use the Google map static map API to show static map inside scroll view and when you tap on scroll view you can open a Scrollable google map in a new window.
The reason behind this is that the Map uses a SurfaceView, when the App creates this view it creates a Window behind your Activity's and punches a hole meaning things in your Activity's window cannot seen underneath the SurfaceView's original location.
For me this is worked like charm, You can use this library
https://github.com/NyxDigital/NiceSupportMapFragment/