Clarifying layout - android

This is my layout:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/ic_assignment" />
<EditText
android:id="#+id/editName"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/under_line_edit"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
android:background="#drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/img"
android:background="#drawable/ic_person_outline" />
<EditText
android:id="#+id/editUsername"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/under_line_edit"/>
</LinearLayout>
</ScrollView>
I don't understand why if I put match_parent on the imageView and editTex, the latter do not occupy the entire screen in height.
Instead I get two rows as I wanted but I do not understand why
Why?

Please try this:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:background="#drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/ic_assignment" />
<EditText
android:id="#+id/editName"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/under_line_edit"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="30dp"
android:background="#drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/img"
android:background="#drawable/ic_person_outline" />
<EditText
android:id="#+id/editUsername"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/under_line_edit"/>
</LinearLayout>
</ScrollView>

Related

Android: Center two elements in a Linear Layout

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>

Android, layout_above not working

I want to display some text in the middle of the screen, below header and above footer. Since this text is very long I nested it in ScrollView. I have tried a number of solutions: this, this, this, this, and a bunch more...
At first I had a problem of the two relative_layouts overlapping and text being cut of. The most accepted answer is to use layout_above and layout_below, but when I use layout_above, the text is never displayed.
This is what my xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/gray"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/profile_photo"
android:src="#drawable/default_profile"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/text"/>-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:background="#color/gray"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/red" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/white"
android:layout_weight="1"
android:gravity="center"
android:text="#string/blue" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:textColor="#color/white"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/green" />
</LinearLayout>
</RelativeLayout>
in your ln_layout_footer
set android:layout_height="wrap_content"
Edited
<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"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray_pressed"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/action_settings"
android:src="#drawable/img_splash_logo"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/txt_price" />-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_quantity"
android:textColor="#color/white" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_material"
android:textColor="#color/white" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/msg_enter_user_name"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
In you layout using two properties that why it doesn't work. So you can remove one properties here is your working code
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp">
<TextView
android:textColor="#000"
android:id="#+id/meetupDescription"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:text="#string/text" />-
</ScrollView>
</RelativeLayout>
you can use this android:layout_below="#+id/linear_layout_header or this android:layout_above="#+id/ln_layout_footer, one property at a time. or simply copy and past

force Image fill all part of SimpleDraweeView area

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

Recycleview not scroll in nested scrollview android

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/todoDetailsCoordinatorLayout"
android:background="#color/windowBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/todoEditMainLl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/windowBackground"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/todoDetailsAppBar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/todoDetailsToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetStart="10dp"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/todoDetailsBottomLl"
android:layout_below="#+id/todoDetailsAppBar"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/todoDetailsScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/todoEditTopLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/windowBackground"
android:orientation="vertical"
android:visibility="visible">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/eight_dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/list_item_single_line_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_user"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center_vertical"
android:orientation="vertical">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditTodoTxtAssignToName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="" />
<com.strait.solvenow.Utilities.WithoutSecondaryTextView
android:id="#+id/EditTodoTxtAssignByName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:src="#drawable/todo_due_date" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditToDoTxtDueDate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:background="#null"
android:gravity="left|center"
android:text="#string/Due_Date" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/todoDetailsImgStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/user_place_holder" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditToDoTxtStatus"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:background="#null"
android:gravity="left|center"
android:text="#string/Status" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center|left"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_notification" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:orientation="horizontal">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/todoDetailsTxtNotify"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/Notifications" />
<android.support.v7.widget.SwitchCompat
android:id="#+id/todoEditTglNotification"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/ten_dp"
android:layout_toRightOf="#+id/todoDetailsTxtNotify"
android:background="#android:color/transparent"
android:button="#null"
android:checked="false"
android:text=""
android:textColor="#color/textColorWithoutPrimary"
android:textOff=""
android:textOn="" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/todoEditImgAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_new_attach" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtAttachment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center|left"
android:text="#string/Attachment" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center|left"
android:orientation="horizontal">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtReminder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Reminder"
android:visibility="visible" />
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtForward"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Forward" />
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtRejected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Reject" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- <android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/todoSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/chatWindowBottomRl">
-->
<android.support.v7.widget.RecyclerView
android:id="#+id/todoRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/five_dp"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/ten_dp"
android:visibility="visible"></android.support.v7.widget.RecyclerView>
<!--</android.support.v4.widget.SwipeRefreshLayout>-->
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/todoDetailsBottomLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<include
android:id="#+id/todoChatBottomVerticalLine"
layout="#layout/divider_view_line"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:background="#color/windowBackground"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin"
android:visibility="visible">
<ImageView
android:id="#+id/todoChatImgAttachment"
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="#dimen/icon_padding"
android:src="#drawable/chat_attachment"
android:visibility="visible" />
<com.strait.solvenow.Utilities.WithoutEditTextView
android:id="#+id/todoChatEdtTextMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/five_dp"
android:layout_toLeftOf="#+id/todoChatImgSend"
android:layout_toRightOf="#+id/todoChatImgAttachment"
android:background="#drawable/chat_window_text_msg_bg"
android:hint=""
android:maxLines="4"
android:minHeight="35dp"
android:paddingLeft="#dimen/ten_dp"
android:text=""
android:textSize="16sp"
android:visibility="visible" />
<ImageView
android:id="#+id/todoChatImgSend"
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="#dimen/icon_padding"
android:src="#drawable/send"
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I have using recycle view inside nested Scroll view but Recycle view not scroll down in nested scroll view.recycle view scroll down when keyboard open and new item add in recycle view.here is above my code.
First of all this is bad layout technique you have implement
According to android standard there are no more than two Scrolling views inside one layout
Make a proper layout for same
You should disable scrolling of recyclerview :
recycler.setNestedScrollingEnabled(false);
You should also set height of recyclerview to wrap_content
android:layout_height="wrap_content"
How to put RecyclerView inside NestedScrollView?

trying to position my checkbox above the keyboard in XML

My activity looks like this:
I use this XML :
<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="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7">
</SearchView>
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:src="#drawable/settingsicon"
android:background="#drawable/ambuttonstatessettings"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contacts_list"></ListView>
</LinearLayout>
But I want it to look like this, with a checkbox above the keyboard. Or if the keyboard is not there, the checkbox should be at the bottom :
Any idea how I can do this ? I tried this code, which is the closest I've come (basically, making a new linear layout at the bottom) but I can't get it right. And can't figure out why.
<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="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7">
</SearchView>
<!--android:drawableLeft="#android:drawable/ic_menu_search"-->
<!--android:queryHint="howdy"-->
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:src="#drawable/settingsicon"
android:background="#drawable/ambuttonstatessettings"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contacts_list"></ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
try this:
<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="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<SearchView
android:layout_width="0px"
android:layout_height="wrap_content"
android:background="#5b74a8"
android:padding="4dp"
android:id="#+id/searchView"
android:singleLine="true"
android:layout_gravity="right"
android:layout_weight="7"/>
<!--android:drawableLeft="#android:drawable/ic_menu_search"-->
<!--android:queryHint="howdy"-->
<ImageButton
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/settingsButton"
android:background="#787878"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="settingsPopUp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:id="#+id/contacts_list"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="20"
android:orientation="horizontal" >
<CheckBox
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="#ffa500"
android:text="New CheckBox"
android:id="#+id/checkBox"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
this is the solution.

Categories

Resources