I have a layout which has and ImageView to the left, and TextView to the right:
<ImageView
android:src="#drawable/alert"
android:id="#+id/articleStoryImage"
android:layout_below="#+id/articleStorySubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
/>
<TextView
android:id="#+id/articleStory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/articleStorySubTitle"
android:layout_toRightOf="#+id/articleStoryImage"
android:gravity="right"
android:inputType="textMultiLine"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:ellipsize="end"
android:layout_marginTop="10sp"
android:textSize="11sp"
android:textColor="#000000" />
What I'm trying to do, is that the TextView text would start to the right of the ImageView,
but would continue below the ImageView. You can call it some kind of overflow.
How can I do that?
Thanks.
EDITED: FULL XML:
<?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"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:id="#+id/articleStoryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb"
android:typeface="sans"
android:gravity="right"
android:ellipsize="end"
android:singleLine="false"
android:inputType="textMultiLine"
android:textSize="25sp"
android:textColor="#DBA118"
android:textStyle="bold" />
<TextView
android:id="#+id/articleStorySubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/articleStoryTitle"
android:gravity="right"
android:inputType="textMultiLine"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb"
android:ellipsize="end"
android:layout_marginTop="10sp"
android:textSize="12sp"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:src="#drawable/alert"
android:id="#+id/articleStoryImage"
android:layout_below="#+id/articleStorySubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
/>
<TextView
android:id="#+id/articleStory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/articleStorySubTitle"
android:layout_toRightOf="#+id/articleStoryImage"
android:gravity="right"
android:inputType="textMultiLine"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:ellipsize="end"
android:layout_marginTop="10sp"
android:textSize="11sp"
android:textColor="#000000" />
</RelativeLayout>
I know you may get better solution but you can ckeck this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tv"
android:layout_width="200dp"
android:layout_height="150dp"
android:layout_alignBottom="#+id/ImageView011"
android:layout_marginTop="22dp"
android:text="hi every body hi every body hi everybodyend"
android:textSize="20dp" />
<ImageView
android:id="#+id/ImageView011"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_marginTop="22dp"
android:layout_marginLeft="22dp"
android:background="#drawable/imag" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_alignParentBottom="true"
android:text=" TextView TextView TextView TextView TextView"
android:textSize="20dp" />
</RelativeLayout>
also check this link : http://dev.androidteam.ru/snippets/textview/leadingmarginspan2
Related
What I want is to make the 'edit' ImageView between '6.4 MB' TextView and '···'TextView, and let 'edit' ImageView close to '···'TextView.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_marginTop="15dp"
android:layout_height="match_parent">
<ImageView
android:src="#drawable/screenshot"
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/screenShot"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
/>
<TextView
android:text="Video Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="23dp"
android:textColor="#000000"
android:id="#+id/videoName"
android:layout_toRightOf="#id/screenShot"
android:layout_alignParentTop="true"
/>
<TextView
android:text="2021.05.19 · 5:11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="#+id/recordDate"
android:layout_toRightOf="#id/screenShot"
android:layout_below="#id/videoName"
/>
<TextView
android:text="6.4 MB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="#+id/videoSize"
android:layout_toRightOf="#id/screenShot"
android:layout_alignBottom="#id/screenShot"
/>
<ImageView
android:src="#drawable/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:id="#+id/edit"
android:layout_toRightOf="#id/videoSize"
android:layout_toLeftOf="#id/edit"
android:layout_alignBottom="#id/screenShot"
/>
<TextView
android:text="···"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="40dp"
android:textColor="#000000"
android:id="#+id/moreAction"
android:layout_alignBottom="#id/screenShot"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
If I use android:layout_marginLeft="40dp" in 'edit' ImageView, then the 'edit' ImageView will disappear.
Why android:layout_marginLeft is noting working?
anyone can help?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/screenShot"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:src="#drawable/ic_launcher_background" />
<TextView
android:id="#+id/videoName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="Video Name"
android:textColor="#000000"
android:textSize="23dp" />
<TextView
android:id="#+id/recordDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/videoName"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="2021.05.19 · 5:11"
android:textColor="#797675"
android:textSize="15dp" />
<TextView
android:id="#+id/videoSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/screenShot"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="6.4 MB"
android:textColor="#797675"
android:textSize="15dp" />
**<ImageView
android:id="#+id/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_alignBottom="#id/screenShot"
android:layout_marginRight="16dp"
android:layout_toLeftOf="#id/moreAction"
android:src="#drawable/ic_baseline_content_cut_24" />**
<TextView
android:id="#+id/moreAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/screenShot"
android:layout_alignParentRight="true"
android:layout_marginLeft="0dp"
android:text="···"
android:textColor="#000000"
android:textSize="40dp" />
I shall remove
android:layout_toLeftOf="#id/edit"
and add
android:layout_marginLeft="170dp"
the complete 'edit' ImageView code is like below:
<ImageView
android:src="#drawable/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:id="#+id/edit"
android:layout_toRightOf="#id/videoSize"
android:layout_marginLeft="170dp"
android:layout_alignBottom="#id/screenShot"
/>
I'm implementing a Recycler View in Android to create a list, but for some reason I see a space in between two elements, and I'm not able to pinpoint the error location. As to why is this happening, my guess is on the row element XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview1="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_top_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/pos_cv"
android:layout_width="match_parent"
android:layout_height="72dp"
android:clickable="true"
cardview1:cardCornerRadius="6dp"
cardview1:cardElevation="4dp"
cardview1:cardMaxElevation="6dp">
<TextView
android:id="#+id/manager1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:text="Store Manager/Branch"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<TextView
android:id="#+id/retail"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Abc Retail"
android:textSize="10sp" />
<View
android:layout_width="170dp"
android:layout_height="match_parent" />
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="25,000"
android:textColor="#color/colorDarkPink"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/address"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
android:text="Abc Retail"
android:textSize="10sp" />
</android.support.v7.widget.CardView>
RecyclerView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/list_view_header_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:weightSum="5"
android:background="#color/colorDarkPink"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top 3 Performers"
android:textStyle="bold"
android:textColor="#color/colorPrimaryLight"
android:layout_weight="3"
android:textSize="16sp"
android:lines="1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sales"
android:textStyle="bold"
android:textColor="#color/colorPrimaryLight"
android:layout_weight="2"
android:textSize="16sp"
android:lines="1"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/performer_lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#color/colorTransparent"
android:layout_marginTop="16dp"
android:dividerHeight="4dp"
/>
It is because of recycler view height. Try to change recyclerview height to wrap_content.And in cardview layout in linear-layout use height wrap_content.
try this code for your cardview:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview1="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/pos_cv"
android:layout_width="match_parent"
android:layout_height="72dp"
android:clickable="true"
android:layout_marginBottom="10dp"
cardview1:cardCornerRadius="6dp"
cardview1:cardElevation="4dp"
cardview1:cardMaxElevation="6dp">
<TextView
android:id="#+id/manager1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:text="Store Manager/Branch"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<TextView
android:id="#+id/retail"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Abc Retail"
android:textSize="10sp" />
<View
android:layout_width="170dp"
android:layout_height="match_parent" />
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="25,000"
android:textColor="#color/colorDarkPink"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/address"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
android:text="Abc Retail"
android:textSize="10sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Try to decrease your values
android:layout_height="50dp"
if it will not work try to decrease values in other views
I have own implementation of marquee class since the user can decide the marquee behavior (No scroll, scroll once, scroll repeat) for the text in my music app. The problem arise whenever user starts to play the songs since it continuously update timer text (id:tv_playtime) in the layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="onButtonHomeClick">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<ImageView
android:layout_width="64.67dp"
android:layout_height="25.33dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="2dp"
android:background="#null"
android:duplicateParentState="true"
android:scaleType="fitStart"
android:visibility="gone" />
</RelativeLayout>
<!--home buttons-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Media Player"
android:textColor="#color/white"
android:textSize="20dp" />
<ImageView
android:id="#+id/iv_settings_btn_passenger"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<!--media player home-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="36dp"
>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:tint="#color/white"
android:visibility="invisible" />
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
</RelativeLayout>
<!-- playing indicator-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="370dp"
>
<RelativeLayout
android:layout_width="240dp"
android:layout_height="240dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true">
<ImageView
android:layout_width="240dp"
android:layout_height="240dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="130dp"
android:layout_marginTop="5dp">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="gone"/>
<ImageView
android:layout_width="30dp"
android:layout_height="24dp"
android:visibility="gone"/>
<ImageView
android:layout_width="30dp"
android:layout_height="24dp"
android:visibility="gone"/>
<myClass.MarqueeTextView
android:id="#+id/marqueetext1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Song Name"
android:textColor="#android:color/white"
android:textSize="24dp" />
<myClass.MarqueeTextView
android:id="#id/marqueetext2"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_below="#+id/marqueetext1"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Artist Name"
android:textColor="#android:color/white"
android:textSize="18dp" />
<myClass.MarqueeTextView
android:id="#id/marqueetext3"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginLeft="60dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Album Name"
android:textColor="#color/white"
android:textSize="18dp"/>
<TextView
android:id="#+id/tv_playtime"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:text="00.00"
android:textColor="#color/white"
android:textSize="18dp" />
</RelativeLayout>
</RelativeLayout>
<!--media player tracks-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="70dip"
android:visibility="gone">
<ImageView
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dip"
/>
<myClass.MarqueeTextView
android:layout_width="match_parent"
android:layout_height="30dip"
android:layout_alignParentBottom="true"
android:layout_marginLeft="14dip"
android:layout_marginRight="5dip"
android:ellipsize="marquee"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<!--mood-->
<myClass.GestureView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!--gestures-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="16dp">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="28dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="20dp"
android:text="00:00"
android:textColor="#android:color/white"
android:textSize="18dp"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="7dip"
android:text="03:50"
android:textColor="#android:color/white"
android:textSize="14dp"
android:textStyle="bold"
android:visibility="gone" />
<SeekBar
style="#style/seekBarMyStyle"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:maxHeight="2dp"
android:minHeight="2dp"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="26dip"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:shadowColor="#color/text_shadow_color"
android:shadowDx="2.5"
android:shadowDy="2.5"
android:shadowRadius="0.01"
android:text="06:18"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/iv_mp_battery"
android:visibility="gone" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:visibility="gone" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/iv_mp_signal"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:background="#color/darkbackgroundcoloralpha"
android:layout_width="match_parent"
android:layout_height="176dp"
android:layout_marginTop="50dp"
android:orientation="vertical"
android:visibility="gone" />
</FrameLayout>
I want to control the scrolling behavior of marqueetext1 here, which is working fine when the song is paused (Since timer text field is not updating).
I've tried similar problems but none of them are working for me
TextView restarts Marquee when changing another TextView in same LinearLayout
Setting of TextView stops marquee scrolling of other TextView
Android, RelativeLayout restarts Marquee-TextView when changing ImageView in same RelativeLayout
Note: Am using gestures for media player control (Next, previous, play, pause)
My assumption is its happening because of the layout since I've done a through debugging in custom Marquee class whose properties are not affecting the marquee restart here. I've override onFocusChanged, onWindowFocusChanged and isFocused methods in my derived Marquee class to make the Textview all focused.What am missing here?
My timer was overlapping on marquee text fields; so limiting the width of the timer text view solved the issue.
<TextView
android:id="#+id/tv_playtime"
android:layout_width="50dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:text="00.00"
android:textColor="#color/white"
android:textSize="18dp" />
I am inflating a ListView with a CardView layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.13"
android:padding="16dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/primary_text" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="112"
android:layout_marginRight="10dp"
android:padding="16dp"
android:paddingLeft="20dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/secondary_text" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="0.04"
android:elegantTextHeight="false"
android:padding="16dp"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/primary_text" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="129"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:padding="16dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="true" />
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>
and here is my ListView layout :
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/listView"
android:visibility="invisible"
android:paddingBottom="0dp"
android:background="#color/grey"
android:layout_gravity="center_horizontal|top"
android:divider="#color/white"
android:cacheColorHint="#android:color/transparent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:fastScrollEnabled="true"
android:layout_marginRight="0dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
The issue here is that I can't have the ripple effect on the card (I can only have it under the card) as you can see it here :
screenshot link
I've tried to put
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
on the cardview, but if I do this, I can't click on the card anymore (the onClick() function doesn't trigger anymore)
Would really appreciate some help understanding this.
It looks like you were close by adding the clickable and background, but you likely just need to select the right view to put the onClick listener on.
Did you try this?
view.findViewById(R.id.card_view).setOnClickListener(new View.OnClickListener)
view would be your LinearLayout with the id of lay.
I have a relative layout in my xml file inside which I have another relative layout which has all my content. My Inner relative layout is loaded with content that comes from my database.
Also I have a edittext and button at bottom for adding comments.
Now the problem is that my inner relative layout doesn't scroll when the content is more but all the contents get hidden inside the bottom edit text and button.
Here is my xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/BG"
android:paddingTop="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
Now I want the inner relative layout’s height to occupy the whole screen and has to be
scrollable when content is more.Have a look at the image below.
Thanks in advance.
Wrap it in ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_view_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
</ScrollView>
To scroll content you need to add ScrollView. ScrollView will be parent of the layout that you want to scroll.
http://developer.android.com/reference/android/widget/ScrollView.html