I have created a 4 rectangle layout using LinearLayout and RelativeLayout combination. Now I want to insert an yellow image (profile image) in the center of first two layouts like the image below:
I am not able to do so? Here is what I have tried. This puts up 2 layouts in the beginning properly.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darkgreen"
android:orientation="vertical">
<LinearLayout
android:id="#+id/profilenameemailID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".12"
android:orientation="horizontal"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingTop="2dp" >
<RelativeLayout
android:id="#+id/profilelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight=".50"
android:background="#color/light_green"
android:gravity="center" >
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/namesysmbol"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:visibility="visible" />
<TextView
android:id="#+id/profilenameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/icon"
android:paddingLeft="2dp"
android:text="#string/defaultname"
android:textColor="#color/nametext"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/emailID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight=".50"
android:background="#color/light_green"
android:gravity="center" >
<ImageView
android:id="#+id/eicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/emailsymbol"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:visibility="visible" />
<TextView
android:id="#+id/emailText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/sicon"
android:paddingLeft="2dp"
android:text="#string/defaultEmail"
android:textColor="#color/emailtext"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
can somebody help me insert the yellow imageView in the center with the above format.
Thanks!
Can you try use this Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="170dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bb4"
android:layout_weight="1"
android:layout_margin="4dp">
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#bb4"
android:layout_margin="4dp">
</LinearLayout>
</LinearLayout>
<!-- Your ImageView here!-->
<View
android:layout_centerInParent="true"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="#ff5"/>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="170dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bb4"
android:layout_weight="1"
android:layout_margin="4dp">
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#bb4"
android:layout_margin="4dp">
</LinearLayout>
</LinearLayout>
</LinearLayout>
This the pseudo code but help you to understand the concept
<LinearLayout orientation= vertical>
<FrameLayout>
<LinearLayout orientation= horizontal>
// make to rectangle here
</LinearLayout>
<Image/> create rounded image here with layout_gravity center
</FrameLayout>
<FrameLayout>
<LinearLayout orientation= horizontal>
// make to rectangle here
</LinearLayout>
</FrameLayout>
</LinearLayout>
Copy and paste in your xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E3E3E3" >
<RelativeLayout
android:id="#+id/r_1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp" >
<View
android:id="#+id/view1"
android:layout_width="5dp"
android:layout_height="1dp"
android:layout_centerInParent="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/view1"
android:background="#666" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/view1"
android:background="#666" >
</RelativeLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:background="#ff00ff" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="#+id/r_1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp" >
<View
android:id="#+id/view2"
android:layout_width="5dp"
android:layout_height="1dp"
android:layout_centerInParent="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/view2"
android:background="#666" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/view2"
android:background="#666" >
</RelativeLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:background="#ff00ff" />
</RelativeLayout>
Related
I want that both elements are centered and without that stretching.
Also, it would be great if the weight was not that wide.
This is how it looks like:
Heres the code:
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/listColor"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#drawable/layout_item_value"
android:text="163,00"
android:textSize="18.2dp"
android:gravity="center_vertical|center_horizontal"
android:id="#+id/txtListValue"
android:textColor="#color/back"
/>
<ImageView
android:id="#+id/image_order"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:scaleX="0.4"
android:scaleY="0.4"
android:gravity="center_vertical|center_horizontal"
/>
Thank You in advance!
Its very simple, you can maintain it with the parent layout itself
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="#+id/txtListValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF1493"
android:text="163,00"
android:textColor="#000000"
android:textSize="30sp" />
<ImageView
android:id="#+id/image_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher" />
</LinearLayout>
try this layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="2">
<TextView
android:id="#+id/txtListValue"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FF1493"
android:gravity="center_vertical|center_horizontal"
android:text="163,00"
android:textColor="#000000"
android:textSize="30sp" />
<ImageView
android:id="#+id/image_order"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:scaleX="0.4"
android:scaleY="0.4"
android:src="#mipmap/ic_launcher" />
</LinearLayout>
Output:
You can use below API without weightsum...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FC226E"
android:gravity="center"
android:text="1,00"
android:textColor="#FFFFFF"
android:textSize="28sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
When I load an image into SimpleDraweeView in fresco liberary it tries to show all image in it so images corners remain empty, How can I force it to scale image to fill whole area?
I tried most of fresco:actualImageScaleType but nothing changes at all.here is my layout
I have set scaleType to centerCrop and nothing changed
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_margin="#dimen/card_margin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="0dp"
card_view:cardPreventCornerOverlap="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:gravity="center|center_horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:focusableInTouchMode="false"
android:focusable="false"
android:baselineAligned="false">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_weight="0.10">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/img_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
fresco:placeholderImage="#drawable/backgrondlayout2"
fresco:actualImageScaleType="centerCrop" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#42000000"
android:layout_gravity="bottom|right"
tools:ignore="RtlHardcoded">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="#android:style/TextAppearance.DeviceDefault.Large"
android:text="Header"
android:transitionName="title"
android:id="#+id/txt_header"
android:layout_gravity="left|center_vertical"
android:gravity="right"
android:padding="#dimen/textPadding"
android:paddingRight="#dimen/textPadding"
tools:ignore="RtlSymmetry"
android:textColor="#color/off_white" />
</FrameLayout>
</FrameLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="90dp"
android:weightSum="1"
android:layout_weight="0.0001"
android:baselineAligned="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="109dp"
android:layout_height="match_parent"
android:layout_weight="0.10">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/img_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.90">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="#android:style/TextAppearance.DeviceDefault.Small"
android:text="Discription"
android:id="#+id/txt_discription"
android:paddingRight="4dp"
android:gravity="right"
tools:ignore="RtlHardcoded,RtlSymmetry" />
</LinearLayout>
</LinearLayout>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#android:drawable/divider_horizontal_textfield"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:paddingBottom="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_weight="0.99"
android:gravity="right|center_horizontal"
tools:ignore="RtlHardcoded"
android:baselineAligned="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_weight="1.75"
android:gravity="center_vertical|center_horizontal">
<ImageView
android:id="#+id/img_distance_icon"
android:contentDescription=""
android:layout_height="24dp"
android:layout_width="24dp"
tools:layout_width="24dp"
android:background="#drawable/ic_directions_black_24dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_weight="0.35"
android:gravity="center|right">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="0.0 km"
android:id="#+id/txt_distance"
android:layout_weight="0.77"
android:gravity="right"
android:paddingRight="#dimen/textPadding"
android:textAlignment="viewStart"
android:paddingLeft="#dimen/textPadding"
android:maxLines="1" />
<TextView
android:layout_width="100dp"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Indoor"
android:id="#+id/txt_indoor"
android:gravity="center|right"
android:textColor="#e00b0b"
android:textSize="18sp"
android:paddingRight="4dp"
android:textAlignment="viewStart"
tools:ignore="RtlHardcoded,RtlSymmetry" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout></android.support.v7.widget.CardView>
</LinearLayout>`
and this is what it shows
Can you please help me find my mistake?
thanks
i want show description of images in Viewflipper slidshow.I need to add textview or button on a viewflipper slideshow.So that only i can display image description based on textview or button click on viewflipper this is my xml
<?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"
android:scaleType="fitXY" >
<ViewFlipper
android:id="#+id/myflipper"
android:layout_width="match_parent"
android:layout_height="300dp"
android:gravity="center"
android:scaleType="fitXY" >
</ViewFlipper>
</LinearLayout>
You can use a FrameLayout for placing TextView over ViewFlipper like shown here:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:id="#+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ViewFlipper
android:id="#+id/myflipper"
android:layout_width="match_parent"
android:layout_height="300dp"
android:gravity="center"
android:scaleType="fitXY" >
</ViewFlipper>
<TextView
android:id="#+id/mytext"
android:layout_width="match_parent"
android:layout_height="30dp"/>
</FrameLayout>
Check out this sample program blog for more examples of how to use FrameLayout.
Happy coding :)
You can use from this way in your Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/KeepToolbar"
android:orientation="vertical">
<ViewFlipper
android:id="#+id/viewflipper"
android:layout_width="match_parent"
android:layout_height="150dp"
android:autoStart="true"
android:background="#color/ORANGE_700"
android:inAnimation="#anim/right_in"
android:outAnimation="#anim/left_out">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/a" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/a"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="AAAA" />
<TextView
android:id="#+id/e"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="asds" />
<TextView
android:id="#+id/w"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="qweqw" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/b" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/b"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="BBBB" />
<TextView
android:id="#+id/u"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="ssd" />
<TextView
android:id="#+id/vb"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="wwee" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/b" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/c"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="CCCC" />
<TextView
android:id="#+id/cd"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="asdfas" />
<TextView
android:id="#+id/cf"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="xxs" />
</LinearLayout>
</LinearLayout>
</ViewFlipper>
I' am trying to achieve sth like this:
But the ListView is overlaps my bottom bar. What is the best way to prevent such a behaviour? As you can see in the picture there is a map under bottom bar. This bottom bar is like target/destination window in Google Maps app.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.gms.maps.MapView
android:id="#+id/map"
tools:layout="#layout/fragmentMap"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical">
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp"/>
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:src="#drawable/draweR"/>
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="40dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal">
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info"
/>
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
Use LinearLayout or RelativeLayout as top most parent instead of FrameLayout.
Here is the code snippet using LinearLayout.
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/draweR"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="#drawable/draweR"/>
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="75" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="25" />
</LinearLayout>
</LinearLayout>
You can mess around with the margins. I got it to look like the image you wanted.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical"
android:paddingBottom="160dp" >
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp" />
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" >
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/draweR" />
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal" >
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info" />
</LinearLayout>
</LinearLayout>
I'm creating layout with ScrollView that have HorizontalScrollView and some EditText.. It looks like the image below..
So far my code is below
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:id="#+id/mainHorizontalScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/image1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/pic1"
android:padding="15dp"
></ImageView>
<ImageView
android:id="#+id/image2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/pic2"
android:padding="15dp"
></ImageView>
<ImageView
android:id="#+id/image3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/pic3"
android:padding="15dp"
></ImageView>
</LinearLayout>
</HorizontalScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textViewPrice"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textViewDetail"
/>
</LinearLayout>
</ScrollView>
My code above make the ScrollView not working..
Is there any way to make the HorizontalScrollView fill the entire screen while some of the TextView is still visible so the user know its scrollable?
Here is my code. It worked for me.
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/casts_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="345dp"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="for demo purpose"
android:textSize="50dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="345dp"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="for demo purpose"
android:textSize="50dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="345dp"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="for demo purpose"
android:textSize="50dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image" />
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
</LinearLayout>
</HorizontalScrollView>