I want to build a UI with responsive design, so I use layout weights. It seems like ScrollView won't scroll with weights. I've tried using ScrollView without weights and the scrolling works fine. I wonder if there's a way to use ScrollView with weights. Here's my code:
<ScrollView 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"
android:fillViewport="true"
android:orientation="vertical"
tools:context=".MainActivity">
<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="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#color/colorAccent"
android:layout_weight="0.3"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#color/colorPrimary"
android:layout_weight="0.7">
<Button
android:layout_width="match_parent"
android:layout_height="200dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="200dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="200dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="200dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="200dp"
android:text="Last Button"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Any help will be appreciated, thanks!
Nested weights are bad for performance. But if you badly need this, You need to remove fixed height of buttons and need to set weight as per weightsum and height should be 0. Make changes as below -
<ScrollView 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"
android:fillViewport="true"
android:orientation="vertical"
tools:context=".MainActivity">
<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="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#color/colorAccent"
android:layout_weight="0.3"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#color/colorPrimary"
android:layout_weight="0.7"
android:weightSum="5">
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Last Button"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Related
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:id="#+id/lnrUpper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnrUpSide"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#color/purple_200"
android:orientation="vertical" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/lnrUpSide"
android:background="#color/white">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="225dp"
android:background="#FFF000" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<LinearLayout
android:id="#+id/fixedHeader"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#color/black"
android:clickable="false"
android:focusable="false">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="FIXED HEADER VIEW"
android:textColor="#color/white"
android:textSize="24sp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fixedHeader">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#F0FE">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#FF0E">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#color/black">
</LinearLayout>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#color/purple_700">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="SECOND FIXED HEADER VIEW"
android:textColor="#color/white"
android:textSize="24sp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="1200dp"
android:background="#color/teal_700">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
</RelativeLayout>
This is my layout xml file and this is how it looks.
This is how my layout look in the first place
When I scroll the layout becomes like this.
Scrolled Layout
However, that is not what I want.
This is the layout I want when I scroll it completely
I was only able to take a screenshot from Android Studio because when I start this at phone the SECOND FIXED HEADER VIEW not got fixed at top. I have tried so many ways but I could not find a solution for this issue. Does anyone know how to make this view ?
So my button and edit text widgets keep getting pushed upwards when I dynamically add text views to my scroll view. So the scrollview's height is also being bumped up. How do I just make sure the scroll view is fixed, I've looked at similar questions and tried implementing it but not working.
<?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:windowSoftInputMode="stateVisible|adjustPan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="#+id/name"
android:hint="Enter name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"/>
<EditText
android:id="#+id/phone_num"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:hint="Enter Phone Number"/>
<Button
android:id="#+id/submit"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="#string/submit_contact"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:isScrollContainer="false"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</LinearLayout>
Try to set all heights to 0dp and give the wheightSum to the parent view. To have a fixed height of the button surround it with a LinearLayout.
<?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:windowSoftInputMode="stateVisible|adjustPan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2.75"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="#+id/name"
android:hint="Enter name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"/>
<EditText
android:id="#+id/phone_num"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:hint="Enter Phone Number"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:orientation="vertical">
<Button
android:id="#+id/submit"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="test"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:isScrollContainer="false"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</LinearLayout>
Try it out, If it dont work you may post what you have tried alredy and the code how you ad the textViews dynamicly. Good luck
Im using adjust pan in my manifest activity and its working properly for scroll view but i have something out of scroll view that is resizing .
i put this code on activity on manifest :
android:windowSoftInputMode="adjustPan"
you can see that in the picture .
im using it beside viewpager :
this is my viewpager xml that contain a lot of edittext .
Fragment 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="match_parent">
<AutoCompleteTextView android:id="#+id/autotext"
android:layout_width="0dp"
android:layout_height="0dp"
android:nextFocusUp="#id/autotext"
android:nextFocusLeft="#id/autotext"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="2">
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/spinnerKind"
android:layout_weight="1"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/spinnerSazande"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/model"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="مدل"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/serial"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="سریال"
android:focusableInTouchMode="true"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/LIMEI"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/IMEI1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="IMEI"
android:gravity="right"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/IMEI2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="IMEI2"
android:gravity="right"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/Size"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="سایز"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/Color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="رنگ"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:id="#+id/LMojdegani"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/MacAddress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="MacAddress"
android:gravity="right"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/mojdegani"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="مژدگانی"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:id="#+id/LFactor"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/FactorNumber"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="شماره فاکتور"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/NameForoshande"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام فروشنده"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:id="#+id/LTarikh"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="1"
>
<EditText
android:id="#+id/Tarikh_Kharid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="تاریخ خرید"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/Name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/LastName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="نام خانوادگی"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/CodeMelli"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="کد ملی 10 رقمی"
android:focusableInTouchMode="true"/>
<EditText
android:id="#+id/Mobile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="شماره موبایل"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal"
android:weightSum="2"
>
<EditText
android:id="#+id/Explain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="توضیحات مربوط به کالا (اختیاری)"
android:focusableInTouchMode="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="vertical"
android:weightSum="2"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="جنسیت"
android:gravity="center_vertical"
android:layout_marginRight="5dp"
android:layout_weight="1"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2">
<RadioButton
android:id="#+id/mard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="مرد"/>
<RadioButton
android:id="#+id/zan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="زن"/>
</RadioGroup>
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="1"
>
<TextView
android:id="#+id/confirm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="تایید"
android:gravity="center"
android:background="#drawable/confirm"
android:layout_weight="1"
android:clickable="true"
android:layout_margin="5dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
and this is my main xml that have a linearlayout with 4 text that is clickable and by selecting on those texts view pager change between pages .
Main XML :
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.85">
<LinearLayout
android:layout_margin="5dp"
android:background="#drawable/card2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="4"
android:layout_weight="1.8">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<TextView
android:gravity="center"
android:text="کالای مسروقه"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/stolled"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<TextView
android:gravity="center"
android:text="کالای گم شده"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/losted"
android:layout_weight="1"
android:clickable="true"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<TextView
android:gravity="center"
android:text="پیدا شده"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/founded"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<TextView
android:gravity="center"
android:text="کالای نو"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/fresh"
android:layout_weight="1"
android:clickable="true"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:id="#+id/ViewPager"
>
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
I think, as per you said in question,you have declared adjustResize in your manifest like below right?
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="landscape"/>
Then, please try to adding
android:fitsSystemWindows="true"
in parent layout of your xml.
Add this line inyour ScrollView android:fillViewport="true"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
(or)
Add this line inside OncreateView() this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);)
serial.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
serial.requestLayout();
getActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
return false;
}
});
I used adjustUnspecified in Manifest and its working properly
Haii.... i need help to design my imageView from this screen shoot to be like this i need the imageView crossed from layout, i am using some of library in this activity like SlidingUpPanel and imageview from CircleImageView if i want to search in google what the keyword or anyone can give me any solution?
here is my layout.xml :
<?xml version="1.0" encoding="utf-8"?>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="100dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoShadowHeight="20dp"
sothree:umanoDragView="#+id/dragView"
tools:context="com.idiots_international.jajan.activities.nearby.NearbyActivity"
sothree:umanoOverlay="true">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_gravity="top"
android:layout_height="wrap_content"
android:orientation="vertical">
<fragment 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:id="#+id/map"
tools:context="com.idiots_international.jajan.activities.nearby.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
<!--map/top view-->
<RelativeLayout android:id="#+id/nearbyRelLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<!---->
<LinearLayout android:layout_width="match_parent"
android:background="#color/colorWhite"
android:layout_height="wrap_content"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:src="#drawable/jajan_logo_3"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
<TextView
android:id="#+id/ShowAddressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Click on Marker to view Address "
android:textColor="#000"
android:textSize="15dp"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"/>
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerView"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</android.support.v7.widget.RecyclerView>
</ScrollView>
</LinearLayout>
<include layout="#layout/layout_bottom_navigation"/>
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
Working but need to remove the outline in here :
Try this,
<!--map/top view-->
<RelativeLayout
android:background="#android:color/transparent"
android:id="#+id/nearbyRelLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<!---->
<LinearLayout
android:layout_marginTop="50dp"
android:layout_width="match_parent"
android:background="#color/colorWhite"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/ShowAddressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Click on Marker to view Address "
android:textColor="#000"
android:textSize="15dp"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"/>
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerView"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</android.support.v7.widget.RecyclerView>
</ScrollView>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="#drawable/jajan_logo_3"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
</RelativeLayout>
Don't use white background for the parent of Circle image view, this will not let see background map.
You can implement this with following layout idea. Feel free to ask if you cant reach requirement
<?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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
// margin top half of circle image view height
android:layout_marginTop="40dp"
>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
Try this way:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:background="#643122"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!--Your Top view (the map) goes here-->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!--Your Bottom view (the text) goes here-->
</LinearLayout>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:src="#drawable/bg"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
</FrameLayout>
OUTPUT IMAGE
I want to create a scrollview with items I add programmatically and at the bottom a fixed button. But with the code below I see no button.
The code:
<LinearLayout
android:id="#+id/list_warrantys"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/show_warratys"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/add_warranty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/mybutton"
android:text="#string/add_button"
android:layout_marginBottom="5dp"/>
</LinearLayout>
<RelativeLayout android:id="#+id/list_warrantys"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_above="#+id/add_warranty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="#+id/show_warratys"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/add_warranty"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/mybutton"
android:text="#string/add_button"
android:layout_marginBottom="5dp"/>
Use RelativeLayout as root and set android:layout_alignParentBottom="true" to your button and android:layout_above="#+id/add_warranty" to your ScrollView