I try to integrate progress bar in my layout. The progress bar cannot fix all screen size. I try to tune the height many times. But no one is suitable for every device. So how can I fix the progress bar height in all screen size.
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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gray_bg"
android:orientation="vertical">
<ImageView
android:id="#+id/bg_pushup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.7"
android:background="#android:color/background_dark"
android:src="#drawable/image_push_up"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/counter_button_close" />
<ImageView
android:id="#+id/btn_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/counter_button_mute" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txt_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="START PUSH-UPS"
android:textColor="#android:color/background_light" />
<RelativeLayout
android:id="#+id/layout_pushup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_start"
android:layout_centerInParent="true"
android:src="#drawable/counter_bg"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:id="#+id/txt_pushup_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="0"
android:textAlignment="center"
android:textColor="#android:color/background_light"
android:textSize="36sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_pushup_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerVertical="false"
android:layout_gravity="center_horizontal"
android:text="0:00"
android:textAlignment="center"
android:textColor="#b5b4ad"
android:textSize="30sp" />
</LinearLayout>
<ProgressBar
android:id="#+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:max="100"
android:progress="75"
android:progressDrawable="#drawable/style_circular"
android:secondaryProgress="100" />
<TextView
android:id="#+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/progressBar2"
android:layout_alignBottom="#+id/progressBar2"
android:layout_centerHorizontal="true"
android:text="TextView"
android:textAlignment="center" />
<ImageView
android:id="#+id/img_shade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView19"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:layout_weight="0.05"
android:src="#drawable/counter_shade" />
<ImageView
android:id="#+id/btn_question_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/progressBar2"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:src="#drawable/question_mark" />
</RelativeLayout>
Progress bar
Please help me to design the xml for all screen size device.
putting the progress bar inside a container and then doing the size will work fine! try like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight = 1>
<ProgressBar
android:id="#+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:max="100"
android:progress="75"
android:progressDrawable="#drawable/style_circular"
android:secondaryProgress="100" />
</LinearLayout>
Related
https://i.stack.imgur.com/VoBbj.gif
the layout is behaving awkward, I am not aware why if anybody could help me with this that will be great.
Whenever I try to open the notification panel, the layout change its position.
<?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"
android:orientation="vertical"
android:background="#color/dark"
>
<RelativeLayout
android:id="#+id/top_card"
android:background="#color/lightDark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
>
<LinearLayout
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:background="#drawable/round"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="30dp"
android:layout_height="35dp"
android:src="#drawable/ic_about"
android:id="#+id/info"
android:contentDescription="#string/todo8">
</ImageView>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/musify"
android:textStyle="bold"
android:layout_toEndOf="#+id/search"
android:layout_toStartOf="#+id/menu_bar"
android:textSize="26sp"
android:textColor="#color/day"
android:textAlignment="center"
android:layout_centerInParent="true"
/>
<LinearLayout
android:id="#+id/menu_bar"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:background="#drawable/round"
android:layout_marginRight="20dp">
<ImageView
android:layout_width="30dp"
android:layout_height="35dp"
android:id="#+id/menu"
android:src="#drawable/ic_menu"
android:contentDescription="#string/todo5" />
</LinearLayout>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_card"
android:layout_below="#+id/top_card"
android:id="#+id/music_recycler_view"
>
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:id="#+id/bottom_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:paddingTop="15dp"
android:background="#drawable/round"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/musicbar_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_centerVertical="true"
android:textColor="#color/day"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
>
<TextView
android:id="#+id/musicbar_artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_centerVertical="true"
android:textColor="#color/day"
android:paddingBottom="5dp"
android:layout_marginStart="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/round"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/_0_00"
android:id="#+id/start_time"
android:textSize="15sp"
android:layout_centerVertical="true"
android:textColor="#color/day"
android:background="#color/lightDark"
android:layout_marginStart="5dp" />
<SeekBar
android:id="#+id/playerseekbar"
android:layout_centerVertical="true"
android:progressDrawable="#drawable/custom_seekbar"
android:progress="0"
android:max="100"
android:thumb="#drawable/custom_thumb"
android:layout_toEndOf="#+id/start_time"
android:layout_toStartOf="#+id/end_time"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/end_time"
android:text="#string/_0_00"
android:textSize="15sp"
android:layout_centerVertical="true"
android:textColor="#color/day"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:gravity="center">
<ImageView
android:id="#+id/prev"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/ic_baseline_skip_previous_24"
android:background="#drawable/round_icon"
android:padding="10dp"
android:contentDescription="#string/todo6" />
<androidx.cardview.widget.CardView
android:id="#+id/play_pause_card"
android:layout_width="90dp"
android:layout_height="100dp"
app:cardBackgroundColor="#color/card"
app:cardCornerRadius="20dp"
app:cardElevation="10dp"
app:cardUseCompatPadding="true"
android:outlineAmbientShadowColor="#color/black"
android:outlineSpotShadowColor="#color/black"
>
<ImageView
android:id="#+id/play_pause_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#drawable/ic_baseline_play_arrow_24"
android:contentDescription="#string/todo1" />
</androidx.cardview.widget.CardView>
<ImageView
android:id="#+id/next"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/ic_baseline_skip_next_24"
android:background="#drawable/round_icon"
android:padding="10dp"
android:contentDescription="#string/todo7" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Help me with this, I have no clue what's happening!
And it would be great if somebody can give me some ideas for the bottom card to make it look good.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
I added this in the onCreate() method, and it worked.
Greetings my fellow programmers,
I've got an easy one i'd guess but i still don't know why it causes such behaviour.
So the scene is this: i've got appliaction which plays music via service and the mini player at the bottom which i've added in a way that i inflated main layout.
If i do not inflate layout with the mini player i can use method's (menu items) inside drawer normally (it takes me to wanted destination and triggers sliding operations flawlessly) once i start playing music i infalte the layout so i show the player and i can do this with drawer :
I can open it from sliding and from hamburger button
I can open it from sliding and from hamburger button
I CAN'T CLOSE it by right-left slide
METHODS DO NOT work inside drawer
Any ideas why inflating messes it up?
P.S
On the main layout i use Coordinator Layout at parent view so i can use floating buttons
***** EDIT: HERE ARE SCREENS ******
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/cili_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.android.listenyo_41.MainActivity"
android:background="#color/white">
<!-- Loading indicator is only shown before the first load -->
<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="com.example.android.listenyo_41.MainActivity"
android:id="#+id/cili_test2"
android:background="#color/black"
>
<!-- Loading indicator is only shown before the first load -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/nesto_glupo"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/black">
<ImageButton
/>
<android.support.v7.widget.Toolbar
/>
<com.miguelcatalan.materialsearchview.MaterialSearchView
/>
</RelativeLayout>
<ListView
/>
<RelativeLayout
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:background="#color/black"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:id="#+id/test_fade"
>
<Button
/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
/>
</android.support.v4.widget.SwipeRefreshLayout>
<!-- Empty view is only visible when the list has no items. -->
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<TextView
/>
<ProgressBar
/>
</RelativeLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/drawer_view"
app:headerLayout="#layout/nav_header"
app:itemIconTint="#color/white"
android:background="#color/black"
app:itemTextColor="#color/white"
/>
</android.support.v4.widget.DrawerLayout>
<ProgressBar
android:id="#+id/picasso_progress"
style="#android:style/Widget.Holo.Light.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#75d9534f"
android:id="#+id/crvena_traka"
>
<RelativeLayout
android:id="#+id/songName_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="135dp"
android:layout_marginTop="5dp"
android:paddingEnd="6dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingStart="6dp"
android:progressDrawable="#drawable/progress_drawable"
android:thumbTint="#color/black"
android:visibility="gone"
/>
<TextView
android:id="#+id/songDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/seekBar"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="140dp"
android:layout_marginTop="2dp"
android:text="00:00:00"
android:textColor="#color/white"
android:textStyle="bold"
android:visibility="gone"
/>
<com.example.android.listenyo_41.ScrollTextView
android:id="#+id/songName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/seekBar"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="2dp"
android:layout_toLeftOf="#id/songDuration"
android:textColor="#color/white"
android:textSize="14sp"
android:textStyle="bold"
android:visibility="gone"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/btn_lay_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="Buffering"
android:textAlignment="center"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="gone"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/player_controler"
android:layout_weight="2">
<ProgressBar
android:id="#+id/loading_indicator2"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:indeterminateDrawable="#drawable/my_border4"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/player_controler2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#color/black"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginTop="20dp"
android:orientation="vertical"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
android:choiceMode="singleChoice"
android:divider="#null"
android:dividerHeight="5dp"
android:orientation="horizontal"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:visibility="gone">
<TextView
android:id="#+id/empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:gravity="center"
android:textAppearance="?android:textAppearanceMedium"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/drawer_view"
app:headerLayout="#layout/nav_header"
app:itemIconTint="#color/white"
android:background="#color/black"
app:itemTextColor="#color/white"
/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
And the mini player
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:id="#+id/play_test"
android:visibility="visible"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#color/myColor"
android:elevation="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp"
android:id="#+id/play_lay"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="#drawable/bl_tran_grad"
>
<RelativeLayout
android:id="#+id/icon_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:onClick="player"
>
<ProgressBar
style="#android:style/Widget.Holo.Light.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:visibility="gone"
android:id="#+id/picasso_progress2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="center"
android:id="#+id/error2"
android:text="Error loading picture"
android:textColor="#color/black"
android:textSize="13sp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_centerInParent="true"
/>
<ImageView
android:id="#+id/player_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
>
</ImageView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_margin="5dp"
android:onClick="player"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:id="#+id/songName2"
android:textSize="14sp"
android:layout_centerVertical="true"
android:textColor="#color/white"
android:textStyle="bold"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="player_2_pause"
>
<ImageView
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_centerInParent="true"
android:src="#drawable/ic_launcher"
android:onClick="player_2_resume"
android:visibility="invisible"
android:id="#+id/player_2_resume"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buffering"
android:textColor="#color/white"
android:layout_centerInParent="true"
android:textSize="14sp"
android:visibility="visible"
android:id="#+id/buffering"
/>
<ImageView
android:layout_width="50dp"
android:layout_height="35dp"
android:src="#drawable/pause2"
android:onClick="player_2_pause"
android:visibility="invisible"
android:id="#+id/player_2_pause"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<SeekBar
android:padding="0dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:id="#+id/seekBar_player2"
android:layout_width="match_parent"
android:layout_height="4.0dp"
android:layout_above="#id/play_lay"
android:background="#80000000"
android:maxHeight="5dp"
android:minHeight="4dp"
android:progressDrawable="#drawable/progress_drawable"
android:max="10"
android:thumb="#color/white"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp" />
</RelativeLayout>
When player active[1]
without player drawer[2]
both[3]
[1]: https://i.stack.imgur.com/gD0BY.jpg
[2]: https://i.stack.imgur.com/0zcYP.jpg
[3]: https://i.stack.imgur.com/qFY6q.jpg
Hi i had to make a layout with card with recyclerview so for that i set an image as a background to linear layout but now i'm unable to center crop that image
My problem is that i cannot use imageview because using that the height of card increases as well and i don't want that so please if someone can assit me..
my xml
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/primary_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="19dp"
android:layout_marginTop="15dp"
app:cardCornerRadius="115dp">
<ImageView
android:id="#+id/background_image_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone" />
<LinearLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:background="#drawable/club1"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:src="#drawable/ellipse" />
<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:padding="5dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="John Doe"
android:textColor="#color/White"
android:textSize="15sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="checked in to"
android:textColor="#color/White"
android:textSize="10sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="W south"
android:textColor="#color/White"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:text="beach mumbai"
android:textColor="#color/White"
android:textSize="15sp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/fifth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/second_text"
android:layout_toRightOf="#+id/fourth_text"
android:text="30 mins ago."
android:textColor="#color/White"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="85dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/sixth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:padding="10dp"
android:text="reply to abc............"
android:textColor="#color/White" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true">
<ImageView
android:id="#+id/favourite_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/ic_favorite_border_black_24dp" />
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/seventh_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="40 likes"
android:textColor="#color/White" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
You can't center crop a background image of linear layout,
But you can achieve the same using these changes:
Replace you LinearLayout with RelativeLayout
Place a ImageView as a first child inside relative layout and use property for center crop.
<RelativeLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:orientation="vertical">
<ImageView
android:scaleType="centerCrop"
android:src="#drawable/club1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
.....
......
</RelativeLayout>
If you Want to control The Image View Scale
you need to put it in ImageView As Src Not Background
You can use Frame layout To Achieve it
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/primary_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="19dp"
android:layout_marginTop="15dp"
app:cardCornerRadius="115dp">
<ImageView
android:id="#+id/background_image_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="210dp">
<ImageView
android:layout_width="match_parent"
android:src="#mipmap/ic_launcher"
android:layout_height="match_parent" />
<LinearLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="210dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/profile_image"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:src="#drawable/playstore_icon" />
<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:padding="5dp">
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="John Doe"
android:textSize="15sp" />
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="checked in to"
android:textSize="10sp" />
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:padding="5dp"
android:text="W south"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:text="beach mumbai"
android:textSize="15sp" />
<TextView
android:id="#+id/fifth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/second_text"
android:layout_toRightOf="#+id/fourth_text"
android:text="30 mins ago."
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="85dp">
<TextView
android:id="#+id/sixth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:padding="10dp"
android:text="reply to abc............"
android:textColor="#color/white" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true">
<ImageView
android:id="#+id/favourite_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/ic_close" />
<TextView
android:id="#+id/seventh_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="40 likes"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</android.support.v7.widget.CardView>
CenterCrop logic is baked inside ImageView. The correct solution is to extract it into a Drawable which wraps another Drawable and centerCrops it.
If you use CoordinatorLayout, then just to put your ImageView with centerCrop parameter to top.
<CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:scaleType="centerCrop"
android:background="#drawable/background_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<include layout="#layout/header_main" />
<TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#android:color/white"
android:background="#drawable/white_border_background"
app:tabIndicatorHeight="3dp"/>
</AppBarLayout>
<ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</CoordinatorLayout>
i'm trying to make (try again) button in center this button is invisible , i already tried to put : android:layout_gravity="center"
but doesn't work any suggestions for resolve this problems
This what he give me :
My XML file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#ffff"
android:id="#+id/activity_viewsol">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:theme="#style/ThemeOverlay.AppCompat.Light"
android:fitsSystemWindows="true"
app:layout_collapseMode="pin"
android:elevation="5dp"
app:navigationIcon="#drawable/ic_back"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="48sp"
android:textStyle="bold"
android:text="Solution"
android:id="#+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:id="#+id/scrollview"
android:stackFromBottom="true"
android:scrollbarSize="10dp"
android:scrollbarThumbVertical="#drawable/scrollbar"
android:transcriptMode="alwaysScroll">
<LinearLayout
android:id="#+id/All_Layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="6dp"
android:padding="15dp">
<TextView
android:typeface="normal"
android:layout_gravity="center"
android:id="#+id/prob"
android:textStyle="bold"
android:textColor="#383838"
android:gravity="center"
android:textSize="45sp"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="20dp">
<View
android:layout_height="1dp"
android:layout_width="500dp"
android:background="#000"
android:layout_gravity="center"/>
<TextView
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="O"
android:textSize="40sp"
android:textColor="#color/colorAccent"
android:textStyle="bold"
android:layout_gravity="center"/>
<View
android:layout_height="1dp"
android:layout_width="500dp"
android:background="#000"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="35sp"
android:textStyle="normal"
android:textColor="#383838"
android:id="#+id/sol"
android:typeface="normal"
android:layout_marginBottom="20dp"/>
<View
android:id="#+id/LineHorizontalTwo"
android:layout_height="1dp"
android:layout_width="1000dp"
android:background="#000"
android:layout_gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_margin="20dp"
android:layout_gravity="start|center"
android:id="#+id/Like"
android:src="#mipmap/ic_like"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_margin="20dp"
android:layout_gravity="end|center"
android:id="#+id/sharesol"
android:src="#mipmap/ic_action_share"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#mipmap/retry"
android:drawablePadding="10dp"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:id="#+id/retry"
android:onClick="onClickRetry"
android:background="#null"
android:padding="6dp"
android:textSize="35sp"
android:text="TRY AGAIN"
android:textColor="#000" />
</LinearLayout>
You can do it simply doing by enclosing your error button inside the Relative Layout as following steps:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="#+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:drawablePadding="10dp"
android:drawableTop="#drawable/ic_android"
android:gravity="center"
android:padding="6dp"
android:text="TRY AGAIN"
android:textColor="#000"
android:textSize="35sp"
android:visibility="visible" />
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
also you need a RelativeLayout for parent of this tag
Make the parent layout as RelativeLayout and put everything inside RelativeLayout except the button.
use
<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">
<!--Put your other codes here-->
<!--everything can be within LinerarLayout-->
<Button
android:id="#+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#null"
android:drawablePadding="10dp"
android:drawableTop="#mipmap/retry"
android:onClick="onClickRetry"
android:padding="6dp"
android:text="TRY AGAIN"
android:textColor="#000"
android:textSize="35sp"
android:visibility="gone" />
</RelativeLayout>
as your button code
I have an image and some text and below that i have a sliding tab layout with a view pager and the view pager has 3 fragments each having one recycler view each . Now my problem is that i want to scroll the recyclerview and at the same time i want to scroll the rest of the elements too. For eg when i scroll the recycler view i want all other views to scroll as well. This my XML layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView7"
android:src="#drawable/aal"
android:adjustViewBounds="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#98000000"
android:id="#+id/innerColor"
android:layout_alignBottom="#+id/imageView7"
android:layout_alignParentTop="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/include"
android:padding="13dp"
>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:clickable="true"
android:background="#drawable/custom_bg"
android:onClick="BackPressed"
android:src="#drawable/ic_arrow_back"
android:id="#+id/imageView2" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:clickable="true"
android:src="#drawable/add"
android:id="#+id/addAction"
android:onClick="showImage"
android:background="#drawable/custom_bg"
android:tint="#color/icons"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sample "
android:textSize="22sp"
android:id="#+id/textHeader"
android:textColor="#ffffff"
android:layout_marginLeft="12dp"
android:scaleType="centerCrop"
android:layout_above="#+id/descText"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:id="#+id/descText"
android:layout_marginLeft="12dp"
android:text="Sampletext"
android:layout_above="#+id/Fbutton"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Follow"
android:onClick="followUnfollow"
android:background="#drawable/follow_button_bg"
android:stateListAnimator="#null"
android:textColor="#403e3e"
android:padding="5dp"
android:id="#+id/Fbutton"
android:layout_alignParentBottom="true"
android:layout_marginBottom="150dp"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Fbutton"
android:layout_marginTop="-80dp"
android:id="#+id/relativeLayout5"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatMem"
android:layout_alignTop="#+id/relativeLayout5"
android:layout_toEndOf="#+id/relativeLayout5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numImages"
android:text="500"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/texts"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="PHOTOS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numImages"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFol"
android:layout_alignTop="#+id/relStatMem"
android:layout_toEndOf="#+id/relStatMem">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numMembers"
android:text="5"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsMembers"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="MEMBERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numMembers"
android:layout_centerHorizontal="true" />
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#ffffff"
android:layout_marginLeft="80dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relStatFols"
android:layout_alignTop="#+id/relStatFol"
android:layout_toEndOf="#+id/relStatFol">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/numFolls"
android:text="1B"
android:textColor="#ffffff"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textsFol"
android:textSize="12dp"
android:textColor="#ffffff"
android:text="FOLLOWERS"
android:layout_marginLeft="30dp"
android:layout_below="#+id/numFolls"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<!--In addition to the two java files we got from google git , this is what you need for tabs-->
<com.example.skmishra.plates.Library.SlidingTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_below="#+id/innerColor"
android:layout_height="wrap_content">
<!--For elevation add here-->
</com.example.skmishra.plates.Library.SlidingTabLayout>
<android.support.v4.view.ViewPager android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/tabs"
android:id="#+id/viewPager"
android:fillViewport="false">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</ScrollView>
Google + Does that , i would like to implement something simillar
I believe Google used a Collapsing Toolbar Layout, which will collaps the toolbar on scroll or other events.
You can find more information here.
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>