Cut layout_height fromt the top - layout

I tried to reduce the height of my app. But when I remove "fill_parent" and change it wih 8dp, it cuts the app from below, how can I cut it from Above?
<?xml version="1.0" encoding="utf-8"?>
<com.lion.multiTabApp.ui.views.WebContent
android:id="#id/webViewPane"
android:visibility="visible"
android:layout_width="fill_parent"
"android:layout_height="8dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.lion.multiTabApp.ui.views.BrowserWebView
android:id="#id/webView"
android:visibility="visible"
android:layout_width="fill_parent"
android:layout_height="8dp" />
<RelativeLayout
android:id="#id/progressbarPanel"
android:visibility="gone"
android:layout_width="fill_parent"
"android:layout_height="8dp"
android:layout_alignParentTop="true">
<TextView
android:textSize="18.0sp"
android:textColor="#ffffffff"
android:gravity="center"
android:id="#id/loadingCurtainDefault"
android:background="#ee000000"
android:visibility="gone"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="8dip"
android:text="#string/loadingPaneTitle"
android:editable="false"
android:layout_below="#id/progressbar"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:id="#id/errorDialogPanel"
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:color="#55000000" />
</com.lion.multiTabApp.ui.views.WebContent>
I tried to modify layout_height and I was expecting to cut the height from the top but it cuts it from the bottom

Related

BottomSheet move to top of screen when changing visibility of its component

I have a bottom sheet with a NestedScrollView inside (see below). When I press on a FAB button, I want to make some parts in this NestedScrollView invisible. But when I change some linearlayouts visibilities to GONE, bottomsheet fly aways from the top.
My XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="#+id/messageOptionBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/back_miscellaneous"
android:gravity="center"
android:orientation="vertical"
app:behavior_peekHeight="0dp"
app:layout_behavior="#string/bottom_sheet_behavior">
<View
android:id="#+id/divider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/textSecondary" />
<LinearLayout
android:id="#+id/layoutDeleteMessage"
android:layout_width="match_parent"
android:layout_height="#dimen/_35sdp"
android:layout_margin="#dimen/_10sdp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:animateLayoutChanges="true"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="#dimen/_22sdp"
android:layout_height="#dimen/_22sdp"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_remove" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10sdp"
android:fontFamily="#font/ubuntu_medium"
android:includeFontPadding="false"
android:text="#string/delete_message"
android:textColor="#color/textSecondary"
android:textSize="#dimen/_12ssp" />
<TextView
android:id="#+id/textConfirmDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/_10sdp"
android:fontFamily="#font/ubuntu_medium"
android:gravity="end"
android:includeFontPadding="false"
android:text="#string/confirm"
android:textColor="#color/red"
android:textSize="#dimen/_12ssp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
Your bottom sheet is moving top because you are using
android:animateLayoutChanges="true"
remove this line from your layoutDeleteMessage (Linear layout)
Hope this solve your problem

recycle view inside scroll view not scrolling

Recycle view is not scrolling inside Scroll View. I have Used Nested Scroll View instead but it doesn't work either. here is My xml code
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/coordinatorlayout"
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"
android:fitsSystemWindows="true">
<include layout="#layout/content_main" />
<android.support.design.widget.AppBarLayout
android:id="#+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay"
app:behavior_scrolling_appbar_peek_height="#dimen/bottom_sheet_peek_height"
app:layout_behavior="com.example.deepdepindersingh.adore.ui.lib.ScrollingAppBarLayoutBehavior">
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
app:behavior_peekHeight="#dimen/bottom_sheet_peek_height"
android:paddingTop="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:id="#+id/bottom_sheet"
app:layout_behavior="com.example.deepdepindersingh.adore.ui.lib.BottomSheetBehaviorGoogleMapsLike"
app:anchorPoint="#dimen/anchor_point"
android:fitsSystemWindows="true">
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:layout_below="#+id/llOptions">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:background="#fff">
</android.support.v7.widget.RecyclerView>
</ScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="#id/bottom_sheet"
app:layout_anchorGravity="top|right|end"
android:src="#android:drawable/ic_dialog_map"
android:layout_margin="#dimen/fab_margin"
app:layout_behavior="com.example.deepdepindersingh.adore.ui.lib.ScrollAwareFABBehavior"
android:clickable="true"/>
</android.support.design.widget.CoordinatorLayout>
and i am using Grid Adapter to display array list
grid-Single.xml
<?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="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/grid_image"
android:layout_width="50dp"
android:layout_height="50dp">
</ImageView>
<TextView
android:id="#+id/grid_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textSize="9sp" />
</LinearLayout>
Please Help in solving my problem.

Overlap the layout in the android ExpandableListView

In the following template , at the above New vhd text,
overlap the row , I want to fix this problem .I tried to change the height of the Main File but no used.I just increase the text Size 14 to 15 PX in the all template ,size increased in main template programmatically, this problem occur. I attached my code with the question also see the commented section in XML file.Please suggest me solution if any.I am new to android .Not familiar with the android.I also attached the image below.Thank you.
//Main file
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" //Changed the height but not work
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:orientation="vertical"
android:background="#color/green">
<TextView
android:id="#+id/queue_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/white"
android:text="Inbox"
android:textStyle="bold"
android:gravity="center_vertical"
android:layout_marginLeft="10dp" />
</LinearLayout>
<ExpandableListView android:id="#+id/que_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" //changed as fill_parent but not worked
android:groupIndicator="#drawable/settings_selector"/>
</LinearLayout>
//Second File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"> //changed as fill_parent but not worked
<TextView android:id="#+id/groupname"
android:paddingLeft="50px"
android:paddingTop="10px"//changed as 15px not worked
android:paddingBottom="10px"//changed as 15px not worked
android:textSize="15px"
android:textColor="#0b730b"
android:layout_width="250px"
android:layout_height="wrap_content"/>//changed as fill_parent but not worked
</LinearLayout>
//Third file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">//changed as fill_parent but not worked
<ImageView
android:id="#+id/imageView1"
android:paddingLeft="40px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/green" />
<TextView android:id="#+id/childname"
android:paddingLeft="20px"
android:paddingTop="10px"
android:paddingBottom="10px"
android:textSize="15px"
android:textColor="#0b730b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="#+id/child_id"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="#+id/dept_id"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="#+id/rgb"
android:textSize="16px"
android:layout_marginLeft="10px"
android:textColor="#0b730b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

Android: How to understand layouts?

I am struggling big time with trying to make a simple layout with two TextView:s under each other on the left and corresponding two TimePicker:s under each other on the right. However, whichever view I use or attributes I choose that seem relevant I do not get the desired outcome. Here is my current try:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
>
<TextView
android:layout_column="1"
android:id="#+id/text_start_time"
android:text="#string/start_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_start"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
>
<TextView
android:layout_column="1"
android:id="#+id/text_end_time"
android:text="#string/end_time"
android:layout_gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_end"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
/>
</TableRow>
<TableRow>
<Button
android:layout_column="2"
android:layout_width="match_parent"
android:text="#string/button_calculate"
android:gravity="center"
android:onClick="calculateWorkingTime"
/>
</TableRow>
</TableLayout>
This gives the following output
Where is "Start"?
As you can see "Start" is not even shown! I would like to align "Start" with the vertical center of the TimePicker spinner. How to do that?
First, don't use a TableLayout. Use Linears, as you are a beginner and they're easier to use and understand. Here's what you should do:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/text_start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/start_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/text_end_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/end_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</LinearLayout>
<Button
android:layout_column="2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/button_calculate"
android:gravity="center"
android:onClick="calculateWorkingTime"
/>
</LinearLayout>
What I've done is creating a Linear Layout and, into it, another two with orientation:horizontal, which makes the elements appear one next to each other.
Also, I've put width and height to all the elements, what is very important.
I've put wrap_content, if you want to change it, no problem.
I didn't test it, if there's any error, just coment
Hope it helps!

How to create a layout which is rounded on all sides?

I have created a layout which is supposed to have rounded corners on all the four sides. However, the layout shows rounded corners only in the left and right top corners. How to create a layout which has rounded corners on all the four sides (including the left and right top corners)? Here is my xml 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="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:background="#FFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/rounded_linearlayout"
android:orientation="vertical"
android:layout_margin="#dimen/welcome_margin">
<TextView
android:text="#string/fitToWork"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="#dimen/margintop_value"
android:layout_marginLeft="#dimen/margin_left_value"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center">
<TextView
android:id="#+id/tv_yes"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/yes"
android:textColor="#FFF"
android:textSize="#dimen/yes_text_size"
android:background="#B5D625"/>
<TextView
android:id="#+id/tv_no"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/no"
android:textColor="#FFF"
android:textSize="#dimen/yes_text_size"
android:background="#2E2E2E"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is the rounded_linearlayout.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFF"/>
<corners android:bottomRightRadius="8dip"
android:bottomLeftRadius="8dip"
android:topRightRadius="8dip"
android:topLeftRadius="8dip"/>
<stroke android:width="1dip" android:color="#AFAFAF"/>
</shape>
Thanks in advance!
If you want rounded corners on all the four sides then my suggestion is use a cardView instead. In cardView you can do it easily using card_view:cardCornerRadius="4dp" this attribute change the value according to your requirement.
Import CardView as a library from support library and add it in your project
Little code snippet
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#android:color/darker_gray"
card_view:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/abc_action_bar_default_height_material"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
android:layout_weight="1"
android:textColor="#android:color/black"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#android:color/black"
android:layout_weight="1"
android:textColor="#android:color/white"
android:text="Button" />
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/abc_background_cache_hint_selector_material_dark" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
First of all, if you need all the corners to be rounded, you don't need to mention all the corners one by one, add this:
<corners android:radius="8dp"/>
I pulled your code and compiled it, it looks like it is working. The only thing is that your buttons are aligned with bottom of your parent LinearLayout and doesn't let you to see the bottom corners. I added a bit of padding to the parent LinearLayout and now all the rounded corners are visible.
EDIT:
I changed your code to this and it worked:
Here is the layout:
<?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:layout_gravity="center"
android:background="#FFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_margin="10dp"
android:background="#drawable/rounded"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:padding="10dp"
android:text="fitToWork" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center" >
<TextView
android:id="#+id/tv_yes"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#B5D625"
android:gravity="center"
android:text="yes"
android:textColor="#FFF"
android:textSize="25sp" />
<TextView
android:id="#+id/tv_no"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#2E2E2E"
android:gravity="center"
android:text="no"
android:textColor="#FFF"
android:textSize="35sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
and here the drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFF" />
<corners
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"
android:topLeftRadius="8dip"
android:topRightRadius="8dip" />
<stroke
android:width="1dip"
android:color="#AFAFAF" />
</shape>
Let me know if it work for you.
Cheers
A.

Resources