Ripple effect isn't fire properly onClick - android

I'm trying to use this lib https://github.com/traex/RippleEffect. I tried the sample and everything works fines but when I try to use this with more views inside the RippleView like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ripple="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:id="#+id/drive_layoutT"
android:layout_height="72dp"
android:weightSum="1"
android:background="#fff"
android:orientation="horizontal">
<com.andexert.library.RippleView
android:id="#+id/rippleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ripple:rv_color="#797979">
<LinearLayout
android:layout_width="fill_parent"
android:id="#+id/drive_layout"
android:layout_height="72dp"
android:weightSum="1"
android:background="#fff"
android:orientation="horizontal">
<ImageView
android:id="#+id/drive_icon"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:padding="4dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="71dp"
android:layout_marginLeft="14dp">
<ImageView
android:id="#+id/drive_menu_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:clickable="true"
android:paddingRight="10dp"
android:src="#drawable/button_overflow_menu"
android:layout_marginRight="2dp" />
<View
android:layout_width="22dp"
android:layout_height="22dp"
android:id="#+id/drive_badge"
android:padding="8dp"
android:background="#drawable/circle"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/drive_menu_btn"
android:layout_toStartOf="#+id/drive_menu_btn" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/drive_name"
android:textColor="#color/grey_list_item_title"
android:textSize="16sp"
android:ellipsize="end"
android:singleLine="true"
android:layout_alignTop="#+id/drive_menu_btn"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/drive_spinner"
android:layout_toStartOf="#+id/drive_spinner" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/drive_details"
android:textColor="#color/grey_list_item_details"
android:textSize="10sp"
android:ellipsize="end"
android:singleLine="true"
android:layout_below="#+id/drive_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/drive_badge"
android:layout_toStartOf="#+id/drive_badge" />
<ProgressBar
style="#style/CustomProgressBar"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="#+id/drive_progress_bar"
android:layout_below="#+id/drive_details"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="3dp"
android:layout_marginRight="16dp"
android:indeterminate="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="9"
android:id="#+id/drive_badge_text"
android:layout_marginRight="6.5dp"
android:layout_marginEnd="6dp"
android:layout_centerVertical="true"
android:layout_alignRight="#+id/drive_badge"
android:layout_alignEnd="#+id/drive_badge" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="+"
android:id="#+id/drive_badge_plus"
android:textSize="7sp"
android:layout_marginRight="3dp"
android:layout_marginEnd="2dp"
android:layout_centerVertical="true"
android:layout_alignRight="#+id/drive_badge"
android:layout_alignEnd="#+id/drive_badge" />
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/drive_spinner"
android:layout_alignBottom="#+id/drive_details"
android:layout_toLeftOf="#+id/drive_badge"
android:layout_toStartOf="#+id/drive_badge"
android:indeterminate="false"
android:layout_marginBottom="3dp" />
</RelativeLayout>
<View
android:id="#+id/drive_divider"
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:background="#color/grey_divider"
android:layout_marginTop="0dp"
android:layout_marginLeft="8dp" />
</LinearLayout>
</LinearLayout>
</com.andexert.library.RippleView>
</LinearLayout>
The ripple effect doesn't fire onClick, if I make a long press click I can see that the ripple effect happens. So this leads to a conclusion which is that this delay is caused because the RippleView is loading all the views inside.
How can I fixe this? Or is there anything I'm getting wrong or any work around for this issue?

Related

Scrollview under the header

Is there a way to do this in android studio? I want to achieve that when you scroll down the header will overlap above and under is the scrollview part. What I've got is it scrolls over the header. In android studio
This is what Im trying to achieve that was made in figma
Default
When you scroll
So far this is what my code looks like
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Fragment.RecordFragment"
android:orientation="vertical">
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="100dp">
<TextView
android:id="#+id/txtDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="128dp"
android:text="Date for today"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="316dp"
android:layout_height="201dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:background="#drawable/sec_bp" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="70dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="SBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="120dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="DBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="170dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="BPM" />
<Button
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="210dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:text="save" />
</RelativeLayout>
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try adding elevation inside your header view. like this :
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/
android:elevation="1dp">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp"
android:elevation="2dp"/>
I set the View elevation 1dp and the TextView 2dp so that the text can still in front of the View.

graph not showing in horizontalscrollview android

i am microcharts.droid.ChartView in xamarin to make a line graph, and i want it to be horizontal scroll able, but by using following code graph is not showing up.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#444444">
<refractored.controls.CircleImageView
app:civ_border_width="2dp"
app:civ_border_color="#FFFFFF"
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/profilepicimageview"
android:src="#drawable/profilepic"
android:scaleType="centerCrop"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp" />
<TextView
android:text="..."
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#id/profilepicimageview"
android:textColor="#android:color/white"
android:id="#+id/txtHomeFullName"
android:layout_marginLeft="5dp" />
<TextView
android:text="12500"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/HomeUserTextViewScore"
android:textColor="#android:color/white"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:layout_marginRight="60dp" />
<ImageView
android:src="#drawable/star"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/imageViewStarHome"
android:scaleType="centerCrop"
android:layout_marginTop="30dp"
android:layout_toLeftOf="#id/HomeUserTextViewScore" />
<ProgressBar
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:maxHeight="15dp"
android:minHeight="15dp"
android:layout_below="#id/imageViewStarHome"
android:id="#+id/progressBarHome"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp" />
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp">
<TextView
android:text="WELCOME TO PERKIT"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#302f2f"
android:textColor="#android:color/white"
android:id="#+id/textViewWelcomeToPerkit" />
<microcharts.droid.ChartView
android:id="#+id/chartView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="#+id/linebtn"
android:layout_height="55dp"
android:layout_width="match_parent"
android:background="#444444"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:src="#drawable/rewardDisabled"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginRight="16dp"
android:background="#drawable/roundedbutton"
android:id="#+id/btnHomeReward" />
<ImageButton
android:src="#drawable/leaderDisabled"
android:id="#+id/btnHomeTournaments"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginRight="8dp"
android:background="#drawable/roundedbutton" />
<ImageButton
android:src="#drawable/settingsDisabled"
android:id="#+id/btnHomeSettings"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginLeft="8dp"
android:background="#drawable/roundedbutton" />
<ImageButton
android:src="#drawable/homeEnabled"
android:id="#+id/btnHomeHome"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_marginLeft="16dp"
android:background="#drawable/roundedbuttonEnabled" />
</LinearLayout>
<TextView
android:text="Loading.."
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#android:color/white"
android:id="#+id/txtLoadingTextHome"
android:gravity="center"
android:background="#8889" />
</RelativeLayout>
i want to make the graph horizontal scroll able. to show on layout.
thanks. how can i achieve it in android.i am developing the app in xamarin android. is there any other good library to achieve this?
Try to specify a fixed layout_width to the chartView

How to properly build a layout?

I'm kinda new with android programming and I can figure out many problems thanks to StackOverflow. But there's a thing where I keep struggle : Layouts.
I use DP as advised but it looks like it's not the ultimate solution.
See below, my XML code and what it what it looks like on my Nexus 5X :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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.damien.dartscorer.MainActivity"
android:clipToPadding="false">
<View
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#b71c1c"/>
<ImageView
android:id="#+id/mask"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
android:scaleType="fitCenter"
android:src="#drawable/targe_mask"
android:visibility="invisible"
android:layout_marginBottom="280dp"/>
<ImageView
android:id="#+id/target"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
android:scaleType="fitCenter"
android:src="#drawable/target"
android:visibility="visible"
android:layout_marginBottom="280dp"/>
<TextView
android:id="#+id/pointTextView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_marginVertical="90dp"
android:background="#drawable/pressed_button"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:textColor="#android:color/white"
android:textSize="20sp"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="315dp">
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
<Button
android:id="#+id/button_x2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/pressed_button"
android:onClick="timesTwoClick"
android:text="x2"
android:textStyle="bold"
android:textSize="18dp"
android:textColor="#ffebee" />
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
<Button
android:id="#+id/btn_25"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/halfb"
android:elevation="9dp"/>
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
<Button
android:id="#+id/btn_missed"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/zero" />
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
<Button
android:id="#+id/btn_50"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/bull" />
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
<Button
android:id="#+id/button_x3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/pressed_button"
android:onClick="timesThreeClick"
android:text="x3"
android:textStyle="bold"
android:textSize="18dp"
android:textColor="#ffebee" />
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1">
</Space>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_gravity="bottom">
<TextView
android:id="#+id/playerName1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="60dp"
android:layout_marginTop="32dp"
android:text="Player"
android:visibility="visible"
android:textSize="24sp" />
<TextView
android:id="#+id/playerName2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="60dp"
android:layout_marginTop="32dp"
android:text="Player"
android:visibility="visible"
android:textSize="24sp" />
<TextView
android:id="#+id/playerName3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/scoreC"
android:layout_marginStart="60dp"
android:text="Player"
android:visibility="visible"
android:textSize="24sp" />
<TextView
android:id="#+id/playerName4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/scoreD"
android:layout_alignParentEnd="true"
android:layout_marginEnd="60dp"
android:text="Player"
android:visibility="visible"
android:textSize="24sp" />
<TextView
android:id="#+id/scoreA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/playerName1"
android:layout_marginStart="60dp"
android:visibility="visible"
android:textSize="18sp"
android:text="Pts" />
<TextView
android:id="#+id/scoreB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/playerName2"
android:layout_marginBottom="24dp"
android:layout_marginEnd="60dp"
android:visibility="visible"
android:textSize="18sp"
android:text="Pts" />
<TextView
android:id="#+id/scoreC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="32dp"
android:layout_marginStart="60dp"
android:visibility="visible"
android:textSize="18sp"
android:text="Pts" />
<TextView
android:id="#+id/scoreD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="32dp"
android:layout_marginEnd="60dp"
android:textSize="18sp"
android:visibility="visible"
android:text="Pts" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/winLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DD000000">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32dp"
android:textColor="#FFEAED"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:id="#+id/winner" />
<Button
android:id="#+id/btn_replay"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="#+id/winner"
android:layout_centerHorizontal="true"
android:layout_marginTop="140dp"
android:background="#drawable/replay" />
<Button
android:id="#+id/btn_home"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="#+id/btn_replay"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="#drawable/home" />
</RelativeLayout>
</FrameLayout>
As you can see on this second image, the layout sucks on a Pixel and yet, the screen don't have huge difference ! So how can I build something a minimum consistent ?
Also, I can't add elevation to my buttons and i don't really know why.
Thanks for helping,
Damien
This is not how an Android XML layout should be, this code does not follow guidelines for UI development like parent and child elements. Please check some codes of XML layouts first then try developing with that.
<?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"
android:clipToPadding="false">
<LinearLayout
android:id="#+id/ll_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#b71c1c"/>
</LinearLayout>
<TextView
android:id="#+id/tv_1"
android:layout_below="#+id/ll_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="Some data"/>
<TextView
android:layout_below="#+id/ll_top"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:text="some other data"/>
</RelativeLayout>
this is a sample code just try this and stud it by changing parameters

Android Image doesn't display on some devices

Android noob here.
I am using an image in an image view.
Image Specs: 750x500 PNG 835.36kb
It displays correctly on all device emulators and on the real device during debug. However after release it doesn't appear to show on some devices.
It's image with src 'main22' which is causing the issues.
Any help resolving this would be much appreciated!
I am using the following xml code:
<?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="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.mattblack.fibreapp.MainActivity"
android:background="#000000">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/main22"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:layout_below="#+id/frameLayout6"
android:nestedScrollingEnabled="false"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="#ffffff"
android:id="#+id/frameLayout"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="INACTIVE"
android:id="#+id/qjumpButton"
android:layout_gravity="center"
android:textColor="#000000"
android:background="#ffffff"
android:textSize="30sp"
android:typeface="normal"
android:onClick="clickFunction"
android:enabled="true"
android:clickable="true"
style="?android:attr/borderlessButtonStyle"
android:textStyle="normal"
android:layout_marginBottom="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Queue Jump"
android:id="#+id/textView2"
android:layout_gravity="center_horizontal|bottom"
android:textSize="20sp"
android:textColor="#e4c353"
android:layout_marginBottom="15dp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="#+id/frameLayout2"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/frameLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="100dp"
android:layout_height="80dp"
android:id="#+id/shakeImage"
android:layout_gravity="center"
android:src="#drawable/shake"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WINNER!"
android:id="#+id/winnerText"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff"
android:textSize="30sp"
android:visibility="invisible"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 x The Prize"
android:id="#+id/prizeText"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textSize="20sp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show at the Bar to Claim before we close."
android:id="#+id/claimText"
android:layout_gravity="center_horizontal|bottom"
android:textColor="#ffffff"
android:visibility="invisible"
android:layout_marginBottom="15dp"
android:textSize="12dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO WIN"
android:id="#+id/nowinText"
android:layout_gravity="center_horizontal|top"
android:textColor="#ffffff"
android:textSize="40sp"
android:layout_marginTop="30dp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Try Again Tomorrow."
android:id="#+id/tryagainText"
android:layout_gravity="center_horizontal|bottom"
android:textColor="#ffffff"
android:textSize="12sp"
android:layout_marginBottom="20dp"
android:visibility="invisible" />
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/down"
android:layout_gravity="center"
android:alpha="0.1"
android:enabled="true"
android:clickable="true"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shake Again Tomorrow."
android:id="#+id/shakeTomorrowText"
android:layout_gravity="center"
android:textSize="15sp"
android:textColor="#ffffff"
android:visibility="invisible" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#ffffff"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/frameLayout3">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HOME"
android:id="#+id/button"
android:layout_gravity="left|center_vertical"
android:background="#ffffff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CODE"
android:id="#+id/button9"
android:layout_gravity="right|center_vertical"
android:background="#ffffff"
android:onClick="profilePageClick" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_alignParentStart="false"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:id="#+id/frameLayout6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FIBRE"
android:id="#+id/textView"
android:layout_gravity="center"
android:textSize="25sp"
android:textColor="#d9bc00" />
</FrameLayout>
</RelativeLayout>
I was facing the same issue. In my case the image was very large in size and that was the reason image was not showing on some device. Just reduce the image size and it will work.

Textview dissapear after changing Visibility of ImageView

Im building a row layout for my ListView and have a problem by it.
Currently my layout looks like this :
XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout_ROW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
>
<ImageView
android:id="#+id/imageView_albumart"
android:layout_alignParentTop="true"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="5dp"
android:background="#color/black"
android:visibility="visible"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/txt_titel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/txt_artist"
android:layout_alignTop="#+id/imageView_albumart"
android:layout_toRightOf="#+id/imageView_albumart"
android:singleLine="true"
android:text="Titel"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="18dp"
android:textSize="17dp"
android:layout_toLeftOf="#+id/imageView_eq_animation"
android:layout_alignLeft="#+id/txt_artist"
android:layout_alignStart="#+id/txt_artist" />
<TextView
android:id="#+id/txt_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView_albumart"
android:layout_marginBottom="16dp"
android:layout_toRightOf="#+id/imageView_albumart"
android:text="Artist"
android:singleLine="true"
android:textSize="13dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_toLeftOf="#+id/imageView_eq_animation" />
<ImageView
android:id="#+id/imageView_eq_animation"
android:layout_width="30dp"
android:layout_height="70dp"
android:src="#drawable/ic_equalizer1_white_36dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
android:layout_alignParentLeft="#+id/txt_artist"
android:layout_alignBottom="#+id/imageView_albumart" />
<TextView
android:id="#+id/txt_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:00"
android:singleLine="true"
android:textSize="10dp"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="#+id/txt_titel"
android:layout_alignParentRight="true" />
</RelativeLayout>
Now when I want to change the visibility of the imageView_albumart to android:visibility="gone" I get this result :
Can you see where my format problem is ? I just want to hide the imgAlbumart so Title and Artist TextViews stand alone.
Set the visibility of the View to View.INVISIBLE instead of View.GONE
Try Like this, You Can Design the UI With Combination of RelativeLayout and LinearLayout. Do search in Google about design pattern and Usage Of Layouts in Android. You Will get ideas.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#null"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView_albumart"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_margin="5dp"
android:background="#android:color/darker_gray"
android:visibility="visible" />
<RelativeLayout
android:id="#+id/RelativeLayout_ROW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#null">
<TextView
android:id="#+id/txt_titel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:singleLine="true"
android:text="Titel"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="17dp" />
<TextView
android:id="#+id/txt_artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_titel"
android:layout_marginBottom="16dp"
android:singleLine="true"
android:text="Artist"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="13dp" />
<ImageView
android:id="#+id/imageView_eq_animation"
android:layout_width="30dp"
android:layout_height="70dp"
android:layout_alignBottom="#+id/txt_artist"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#drawable/ic_game"
android:visibility="gone" />
<TextView
android:id="#+id/txt_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/imageView_eq_animation"
android:singleLine="true"
android:text="0:00"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="10dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
Yes there is problem in your layout
change your layout to this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout_ROW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imageView_albumart"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="5dp"
android:background="#000"
android:visibility="gone"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/txt_titel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/imageView_albumart"
android:text="Titel"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="18dp"
android:textSize="17sp"
android:layout_toLeftOf="#+id/imageView_eq_animation"
/>
<TextView
android:id="#+id/txt_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView_albumart"
android:layout_marginBottom="16dp"
android:layout_toRightOf="#+id/imageView_albumart"
android:text="Artist"
android:singleLine="true"
android:layout_below="#+id/txt_titel"
android:textSize="13dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_toLeftOf="#+id/imageView_eq_animation" />
<ImageView
android:id="#+id/imageView_eq_animation"
android:layout_width="30dp"
android:layout_height="70dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="visible"
android:layout_alignParentLeft="#+id/txt_artist"
android:layout_alignBottom="#+id/imageView_albumart" />
<TextView
android:id="#+id/txt_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:00"
android:singleLine="true"
android:textSize="10dp"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="#+id/txt_titel"
android:layout_alignParentRight="true" />
it will do..

Categories

Resources