in an XML file, I have 4 tablelayouts in which the rows are being created dynamically when the user inputs an item. however i want to give each table a specific space of the UI and then just have a scrollbar in each table in case there are too many items in each table.
How can i do that please?
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/AbsoluteLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/loggedas" />
<Space
android:layout_width="58dp"
android:layout_height="1dp" />
<Space
android:layout_width="46dp"
android:layout_height="1dp" />
<Space
android:layout_width="346dp"
android:layout_height="1dp" />
<Space
android:layout_width="1dp"
android:layout_height="51dp" />
<Space
android:layout_width="1dp"
android:layout_height="23dp" />
<Space
android:layout_width="1dp"
android:layout_height="50dp" />
<Space
android:layout_width="1dp"
android:layout_height="10dp" />
<Space
android:layout_width="1dp"
android:layout_height="82dp" />
<Space
android:layout_width="1dp"
android:layout_height="69dp" />
<Space
android:layout_width="1dp"
android:layout_height="66dp" />
<Space
android:layout_width="1dp"
android:layout_height="21dp" />
<Space
android:layout_width="60dp"
android:layout_height="1dp" />
<Space
android:layout_width="30dp"
android:layout_height="1dp" />
<Space
android:layout_width="10dp"
android:layout_height="1dp" />
<TextView
android:id="#+id/loggedastoedit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="138dp"
android:layout_y="0dp"
android:text="#string/loggedas"
android:textColor="#color/Black" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="1dp"
android:layout_y="15dp"
android:text="#string/youneed" />
<TextView
android:id="#+id/caloriesneeded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="66dp"
android:layout_y="16dp"
android:text="TextView"
android:textColor="#color/Red" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="146dp"
android:layout_y="17dp"
android:text="#string/caloriestextfield" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="191dp"
android:layout_y="17dp"
android:text="#string/today" />
<TableLayout
android:id="#+id/breakfasttableviewing"
android:layout_width="344dp"
android:layout_height="wrap_content"
android:layout_x="1dp"
android:layout_y="62dp" >
</TableLayout>
<TableLayout
android:id="#+id/lunchtableviewing"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="135dp" >
</TableLayout>
<TableLayout
android:id="#+id/dinnertableviewing"
android:layout_width="346dp"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="210dp" >
</TableLayout>
<Button
android:id="#+id/addexercisebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="373dp"
android:text="#string/addexercise" />
<Button
android:id="#+id/addmealbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="121dp"
android:layout_y="373dp"
android:text="#string/addfood" />
<Button
android:id="#+id/newday"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="209dp"
android:layout_y="373dp"
android:text="#string/newday" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="111dp"
android:layout_y="43dp"
android:text="#string/breakfast"
android:textStyle="bold" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_x="120dp"
android:layout_y="107dp"
android:text="#string/lunch"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="121dp"
android:layout_y="184dp"
android:text="#string/dinner"
android:textStyle="bold" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="116dp"
android:layout_y="265dp"
android:text="#string/exercise"
android:textStyle="bold" />
<TableLayout
android:id="#+id/exercisetableviewing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="5dp"
android:layout_y="289dp" >
</TableLayout>
Wrap each tableView with ScrollView, and set on each ScrollView android:layout_weight property to divide the screen among them with proportions you desire;
Related
I want to make my whole layout scrollable I have try several ways, but that did't work. Below is my XML code. Actually, the issue I was facing is when I don't make my whole layout scrollable, my listview shows 4 to 5 items. When I try to make my whole parent layout scrollable, my list view only shows one item and another item I can only see by scrolling. means its leave empty space.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="#drawable/bg_gradient"
android:orientation="vertical"
android:padding="25dp">
<LinearLayout
android:id="#+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:id="#+id/addressContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/address_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jaipur, IN"
android:textColor="#color/colorWhite"
android:textSize="24dp" />
<TextView
android:id="#+id/updated_at_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20 April 2012, 20:08 PM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/overviewContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:id="#+id/status_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Clear Sky"
android:textColor="#color/colorWhite"
android:textSize="18dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/temp_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="sans-serif-thin"
android:text="30"
android:textColor="#color/colorWhite"
android:textSize="90dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:text="°C"
android:textColor="#color/colorWhite"
android:textSize="90dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Min Temp: "
android:textColor="#color/colorWhite" />
<TextView
android:id="#+id/temp_min_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30"
android:textColor="#color/colorWhite" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:text="°C"
android:textColor="#color/colorWhite" />
</LinearLayout>
<Space
android:layout_width="50dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Max Temp: "
android:textColor="#color/colorWhite" />
<TextView
android:id="#+id/temp_max_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="35"
android:textColor="#color/colorWhite" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:text="°C"
android:textColor="#color/colorWhite" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="20dp" />
<LinearLayout
android:id="#+id/detailsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/sunrise"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sunrise"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/sunrise_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="06:40 AM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
<Space
android:layout_width="10dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/sunset"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sunset"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/sunset_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="06:40 AM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
<Space
android:layout_width="10dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/wind"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wind"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/wind_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="06:40 AM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/pressure"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pressure"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/pressure_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="06:40 AM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
<Space
android:layout_width="10dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/humidity"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Humidity"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/humidity_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="06:40 AM"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
<Space
android:layout_width="10dp"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3CF1EBF1"
android:gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/info"
app:tint="#FFFFFF" />
<Space
android:layout_width="wrap_content"
android:layout_height="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data By"
android:textColor="#color/colorWhite"
android:textSize="12dp" />
<TextView
android:id="#+id/about_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WeatherMap"
android:textColor="#color/colorWhite"
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weather Forecast of Next 5 Days"
android:textColor="#color/colorWhite"
android:textSize="14sp"
android:layout_gravity="center"/>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp" />
<ListView
android:id="#+id/forecast_listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3CF1EBF1"
android:scrollbars="none"
/>
</LinearLayout>
</RelativeLayout>
Try wrapping the whole thing with a NestedScrollView like what Ali Eid suggested. That will do the trick.
I need to define Table which has a combined vertical and horizontal orientation.
I have tried a variety of XML definitions but have been unsuccessful so far.
My current code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.appname.td.MainActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tlGridTable" >
<TableRow>
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<ImageView
android:id="#+id/icon"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="#drawable/left_logo_dummy" />
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:layout_column="1"
android:textSize="13sp"
android:text="Name" />
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:rotation="270"
android:textSize="13sp"
android:layout_height="match_parent"
android:layout_width="18dp"
android:text="29-May"
android:background="#00ff22"/>
<View
android:rotation="0"
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:textSize="13sp"
android:text="30-May"
android:layout_width="18dp"
android:background="#00ff22" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF9090" />
<TableRow>
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:textSize="13sp"
android:layout_width="18dp"
android:layout_height="18dp"
android:text="1"
android:background="#00ff22"/>
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#ff9090" />
<TextView
android:layout_column="1"
android:layout_width="match_parent"
android:textSize="13sp"
android:text="Uttam" />
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:textSize="13sp"
android:layout_width="18dp"
android:text="Y"
android:background="#00ff22" />
<View
android:layout_width="2dp"
android:layout_height="18dp"
android:background="#FF9090" />
<TextView
android:textSize="13sp"
android:layout_width="18dp"
android:text="N"
android:background="#00ff22" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF9090" />
</TableLayout>
</android.support.constraint.ConstraintLayout>
I am experimenting only with the cell containing "29-May". Since the second row and onwards each cell contains only one letter "Y" or "N", I would like the dates to be vertically aligned with the "2" in "29-May" at the bottom.
Whatever I try, I am unable to get a horizontal width of 18dp to that column and vertical height of 108dp. If I change "layout_height" to 108dp, the entire cell becomes a square of 108dp x 108dp.
What I am doing wrong is quite trivial but I cannot for the world fathom what it is.
Can someone here help?
You should use ListView with Custom adapter with below layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#color/BGo"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Date"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView2"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Day"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView3"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Activity Type"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView4"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Location Planned"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView5"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Remark"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView6"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Status"
android:textColor="#color/White" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#color/BGo"
android:dividerHeight="1dp" >
</ListView>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
I am creating a layout in android but I am not able to create a responsive layout. I have defined font size in pt but it distort on small screen. What should I do to make it responsive for all device. I have worst problem of font size. Screenshot on small screen is:
// My code
<?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="wrap_content"
android:layout_margin="#dimen/activity_horizontal_margin"
android:background="#drawable/background_car_detail"
android:elevation="#dimen/activity_8_margin"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="2">
<FrameLayout
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_margin="0dp"
android:layout_weight=".8"
android:background="#drawable/car">
<TextView
android:id="#+id/txtCertified"
style="#android:style/TextAppearance.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginTop="#dimen/activity_8_margin"
android:alpha="0.5"
android:background="#drawable/btn_right_curve"
android:backgroundTint="#color/colorBlack"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="2dp"
android:text="Certified"
android:textColor="#color/colorWhite" />
<TextView
android:id="#+id/status"
style="#android:style/TextAppearance.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/activity_8_margin"
android:background="#drawable/btn_background"
android:backgroundTint="#color/colorPrimary"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="2dp"
android:text="Sold"
android:textColor="#color/colorWhite" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_weight="1.2"
android:gravity="right"
android:orientation="vertical"
android:padding="#dimen/activity_horizontal_margin">
<TextView
android:id="#+id/carName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mahindra TUV300 T6 Plus"
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/carKm"
style="#android:style/TextAppearance.DeviceDefault.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29,6789 Km"
android:textSize="5pt" />
<View
android:layout_width="1dp"
android:layout_height="10dp"
android:layout_marginLeft="2pt"
android:layout_marginRight="2pt"
android:background="#000000" />
<TextView
android:id="#+id/carType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Disel"
android:textSize="5pt" />
<View
android:layout_width="1dp"
android:layout_height="10dp"
android:layout_marginLeft="2pt"
android:layout_marginRight="2pt"
android:background="#000000" />
<TextView
android:id="#+id/carYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2016"
android:textSize="5pt" />
</LinearLayout>
<TextView
android:id="#+id/carCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Condition: Excellent"
android:textSize="5pt" />
<TextView
android:id="#+id/carAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="Rs. 7.5L"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/carAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Singh car, Rajori Garden, Delhi"
android:textSize="5pt" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Check this out.
<?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="wrap_content"
android:layout_margin="#dimen/activity_horizontal_margin"
android:background="#drawable/rounded_corner_bg"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal"
android:weightSum="2"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight=".8"
android:background="#drawable/com_facebook_button_like_background">
<TextView
android:id="#+id/txtCertified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="top|left"
android:layout_marginTop="20dp"
android:background="#drawable/red_button_background"
android:padding="5dp"
android:text="Certified"
android:textColor="#color/colorAccent"
android:textSize="12sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/red_button_background"
android:gravity="end"
android:padding="5dp"
android:paddingBottom="2dp"
android:text="Sold"
android:textColor="#color/colorAccent" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="right|center"
android:orientation="vertical">
<TextView
android:id="#+id/carName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mahindra TUV300 T6 Plus"
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/carKm"
style="#android:style/TextAppearance.DeviceDefault.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29,6789 Km"
android:textSize="5pt" />
<View
android:layout_width="1dp"
android:layout_height="10dp"
android:layout_marginLeft="2pt"
android:layout_marginRight="2pt"
android:background="#000000" />
<TextView
android:id="#+id/carType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Disel"
android:textSize="5pt" />
<View
android:layout_width="1dp"
android:layout_height="10dp"
android:layout_marginLeft="2pt"
android:layout_marginRight="2pt"
android:background="#000000" />
<TextView
android:id="#+id/carYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2016"
android:textSize="5pt" />
</LinearLayout>
<TextView
android:id="#+id/carCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Condition: Excellent"
android:textSize="5pt" />
<TextView
android:id="#+id/carAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="Rs. 7.5L"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/carAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Singh car, Rajori Garden, Delhi"
android:textSize="5pt" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Ok, after trying any solution I found I decided to put my code in here for help.
I get HTML from JSON and I place it in a TextView to show it.
This is it:
hoursTextView.setText(Html.fromHtml(hours));
hoursTextView.setVisibility(View.VISIBLE);
My problem is, that whenever the content above this TextView takes alot of height, I see only cutted top letters of this TextView and I can't scroll down!
This is my Layout XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
>
<ProgressBar
android:id="#+id/loadData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/coverImg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_marginBottom="5dp"
/>
<TextView
android:id="#+id/fbAbout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/coverImg"
android:gravity="center"
/>
<View
android:id="#+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#eeeeee"
android:layout_below="#+id/fbAbout"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/seperator"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
>
<TextView
android:id="#+id/type"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/beer"
android:drawablePadding="5dp"
android:text="TYPE"
android:layout_weight="1"
/>
<TextView
android:id="#+id/age"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/age_big"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="AGE"
android:layout_weight="1"
/>
<Button
android:id="#+id/callToPlace"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/ic_call_black_24dp"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="CALL"
android:layout_weight="1"
/>
<Button
android:id="#+id/nav"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/navigate"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="navigate"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="HOURS"
android:id="#+id/hoursTitle"
android:layout_below="#+id/buttons"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:layout_marginTop="10dp"
/>
<!--This is the TextView which is cut -->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</RelativeLayout>
The last TextView, with the ID of hours, is being cut on the bottom of the screen.
Hope someone can help me with this,
thanks!
You can use ScrollView for full screen.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/output">
<ProgressBar
android:id="#+id/loadData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/coverImg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_marginBottom="5dp"
/>
<TextView
android:id="#+id/fbAbout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/coverImg"
android:gravity="center"
/>
<View
android:id="#+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#eeeeee"
android:layout_below="#+id/fbAbout"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/seperator"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
>
<TextView
android:id="#+id/type"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/beer"
android:drawablePadding="5dp"
android:text="TYPE"
android:layout_weight="1"
/>
<TextView
android:id="#+id/age"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/age_big"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="AGE"
android:layout_weight="1"
/>
<Button
android:id="#+id/callToPlace"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/ic_call_black_24dp"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="CALL"
android:layout_weight="1"
/>
<Button
android:id="#+id/nav"
android:layout_width="0dp"
android:layout_height="70dp"
android:background="#drawable/circle_text"
android:textAlignment="center"
android:gravity="center"
android:padding="10dp"
android:drawableTop="#drawable/navigate"
android:drawablePadding="5dp"
android:layout_marginStart="10dp"
android:text="navigate"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="HOURS"
android:id="#+id/hoursTitle"
android:layout_below="#+id/buttons"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:layout_marginTop="10dp"
/>
<!--This is the TextView which is cut -->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</ScrollView>
Another Example:
<?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="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 3" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 4" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 5" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton 1" />
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton 2" />
<ToggleButton
android:id="#+id/toggleButton1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ToggleButton" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 6" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 7" />
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 8" />
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 9" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 10" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 11" />
</LinearLayout>
</ScrollView>
Add the scroll view
<ScrollView
android:layout_width="match_parent"
android:layout_height="150dp" >
<!--Just assume it whatever your height is-->
<TextView
android:id="#+id/hours"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_below="#+id/hoursTitle"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:gravity="center"
/>
</ScrollView>
This Is My Xml.
.
<RelativeLayout 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"
tools:context="com.xxx.xxx.MyActivity" >
<LinearLayout
android:id="#+id/viewFromDateToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="#+id/txtFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="#string/txtFromDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="#dimen/generalTextSize" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="#string/lblFromTo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="#dimen/generalTextSize" />
<EditText
android:id="#+id/txtToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="#string/txtToDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="#dimen/generalTextSize" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/green_button_department"
android:text="#string/btnShowData"
android:textColor="#color/white" />
</LinearLayout>
<View
android:id="#+id/upperSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#id/viewFromDateToDate"
android:layout_marginTop="15dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/viewTimeOffDetailsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/upperSeparator"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="#string/txtHeaderTimeOff"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/txtHeaderDate"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/txtHeaderHours"
android:textSize="#dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txtHeaderAction"
android:textSize="#dimen/generalTextSize" />
</LinearLayout>
<View
android:id="#+id/lowerSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#id/viewTimeOffDetailsHeader"
android:background="#android:color/darker_gray" />
<ScrollView
android:id="#+id/scrollDiv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lowerSeparator" >
<LinearLayout
android:id="#+id/viewTimeOffDetailsArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/viewTimeOffDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:background="#drawable/green_button_department"
android:text="#string/btnSubmitTimeOff"
android:textColor="#color/white"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
I want my LinerLayout scrollDiv to Be in Between of lowerSeparator and viewTimeOffDetailsFooter But the problem is ScrolView is still displaying it's Elements After viewTimeOffDetailsFooter Starts.
.
Here is an output.
Of XML Layout
Here you can see the Buttons of scrollDiv Still Displays after viewTimeOffDetailsFooter Buttons. I know that i should not put whole File But i am not getting proper solution that's why. Thanks.
you just need to place it above the viewTimeOffDetailsFooter, by adding below attribute to your scrollDiv
android:layout_above="#+id/viewTimeOffDetailsFooter"
Your viewTimeOffDetailsFooter doesn't have any positional link with scrollDiv, so add to it new rule android:layout_below="#id/scrollDiv". It can work only without android:layout_alignParentBottom="true" rule - need to try.