How to disable horizontal scrolling in crystal seek bar Android - java

I am using crystal seekbar for horizontal scroll but i need to disable the scrolling...I have relative layout with crystakseekbar inside relative layout with disable mode so don't want to scroll the crystalseekbar when layout in disable mode.
<RelativeLayout
android:id="#+id/adjust_card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/adjust_card_disable_background"
android:layout_below="#+id/card_layout"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:paddingBottom="40dp"
android:paddingTop="40dp">
<RelativeLayout
android:id="#+id/adjust_text_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/select_card_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/select_card"
android:layout_centerHorizontal="true"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold"
android:visibility="visible"/>
<TextView
android:id="#+id/adjust_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Adjust values for"
android:textColor="#color/white"
android:textSize="15sp"
android:visibility="gone"/>
<TextView
android:id="#+id/shop_visit_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Shop"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold"
android:layout_toRightOf="#+id/adjust_text"
android:visibility="gone"
android:layout_marginLeft="5dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_below="#+id/adjust_text_layout"
android:layout_marginBottom="20dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/adjust_hours_layout"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/adjustHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Adjust Hours"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="15sp"
android:paddingBottom="5dp"
android:layout_alignBottom="#+id/adjust_hours"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"/>
<TextView
android:id="#+id/adjust_hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:background="#A2B0BE"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="#color/white"
android:textSize="20sp"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"/>
</RelativeLayout>
<com.crystal.crystalrangeseekbar.widgets.CrystalSeekbar
android:id="#+id/rangeSeekbar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/adjust_hours_layout"
android:layout_marginTop="30dp"
app:bar_color="#color/hours_back"
app:bar_highlight_color="#color/btn_back"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:left_thumb_color="#color/white"
app:left_thumb_color_pressed="#color/white"
app:corner_radius="05"
app:data_type="_integer"
/>
<TextView
android:id="#+id/textMin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MIN"
android:layout_below="#id/rangeSeekbar1"
android:layout_marginTop="3dp"
android:layout_alignLeft="#+id/rangeSeekbar1"
android:layout_marginLeft="12dp"
android:textSize="13dp"
android:textColor="#color/white"/>
<TextView
android:id="#+id/textMax1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MAX"
android:layout_below="#id/rangeSeekbar1"
android:layout_marginTop="3dp"
android:textSize="13dp"
android:textColor="#color/white"
android:layout_alignRight="#+id/rangeSeekbar1"
android:layout_marginRight="12dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/adjust_mr_layout"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/adjustMr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Adjust Mr"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="15sp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:paddingBottom="5dp"
android:layout_alignBottom="#+id/adjust_mr"/>
<TextView
android:id="#+id/adjust_mr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:background="#A2B0BE"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textColor="#color/white"
android:textSize="20sp"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"/>
</RelativeLayout>
<com.crystal.crystalrangeseekbar.widgets.CrystalSeekbar
android:id="#+id/rangeSeekbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/adjust_mr_layout"
android:layout_marginTop="30dp"
app:bar_color="#A2B0BE"
app:bar_highlight_color="#color/btn_back"
app:left_thumb_color="#color/white"
app:left_thumb_color_pressed="#color/white"
app:corner_radius="05"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:data_type="_integer"
/>
<TextView
android:id="#+id/textMin2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MIN"
android:layout_below="#id/rangeSeekbar2"
android:layout_marginTop="3dp"
android:layout_alignLeft="#+id/rangeSeekbar2"
android:textSize="13dp"
android:textColor="#color/white"
android:layout_marginLeft="12dp"/>
<TextView
android:id="#+id/textMax2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MAX"
android:layout_below="#id/rangeSeekbar2"
android:layout_marginTop="3dp"
android:textSize="13dp"
android:textColor="#color/white"
android:layout_alignRight="#+id/rangeSeekbar2"
android:layout_marginRight="12dp"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

Disabling the parent layout is OK. But this will not disable the inner children. To disable the seekbar, you have to write seekbar.setEnabled(false);

Related

XML Layout Material Card View border not showing

So I made a layout with Frame Layout and Scroll View. There are 3 material card view inside scroll view. But I dont know why the third card border is not showing and sometimes only the bottom border is missing. I think is because of the constraint and scroll view but I still cant solve it. Anyone knows?
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cv_item_info"
android:layout_width="match_parent"
android:layout_height="100dp"
android:backgroundTint="#color/white"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/tv_item_nama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/nama_item"
android:textColorHint="#color/black"
android:fontFamily="#font/poppins_medium"
android:text=""
android:textStyle="bold"
android:textSize="14sp"
android:textColor="#color/black"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="#+id/tv_item_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="#string/category_item"
android:text=""
android:fontFamily="#font/poppins"
android:textSize="11sp"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="#+id/tv_item_harga"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="#string/harga_item"
android:textColorHint="#color/black"
android:text=""
android:fontFamily="#font/poppins"
android:textSize="14sp"
android:textColor="#color/black"
android:maxLines="1"
android:ellipsize="end" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cv_seller_profile"
android:layout_width="match_parent"
android:layout_height="100dp"
android:backgroundTint="#color/white"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
app:layout_constraintTop_toBottomOf="#id/cv_item_info"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp">
<androidx.cardview.widget.CardView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
app:cardCornerRadius="20dp">
<ImageView
android:id="#+id/iv_seller_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#mipmap/ic_launcher"
android:contentDescription="#string/seller_picture" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_seller_nama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="#font/poppins_medium"
android:textStyle="bold"
android:textColor="#color/black"
android:text=""
android:textSize="14sp"
android:hint="#string/seller_name"
android:textColorHint="#color/black"/>
<TextView
android:id="#+id/tv_seller_city"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:textSize="11sp"
android:text=""
android:fontFamily="#font/poppins"
android:hint="#string/seller_city"/>
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cv_item_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
app:layout_constraintTop_toBottomOf="#id/cv_seller_profile"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/deskripsi"
android:fontFamily="#font/poppins_medium"
android:textColorHint="#color/black"
android:textStyle="bold"
android:textSize="14sp"
android:textColor="#color/black"
android:text=""/>
<TextView
android:id="#+id/tv_deskripsi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Test"
android:fontFamily="#font/poppins"
android:textSize="14sp"
android:textColor="#color/black" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Here is the example image of the layout I made.
ImageLayout
It happens because you do not have a bottom constraint on your last card.
Add a constraint there, and your card will be displayed correctly

TextView overlaps with another textview

I want the text to be displayed to the right of the name,but if the name is too large, the text on the right doesn't fit on the screen. I used the following solution, but it causes the first textview to stretch beyond the size of the text in it.
What I have:
screenshot
What I want:
concept
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_weight="1"
android:fontFamily="#font/montserrat"
android:singleLine="true"
android:text="1"
android:textColor="#color/colorText"
android:textSize="20sp" />
<TextView
android:id="#+id/readed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:background="#drawable/back_new"
android:fontFamily="#font/montserrat"
android:gravity="center"
android:keepScreenOn="true"
android:paddingHorizontal="5dp"
android:paddingVertical="3dp"
android:singleLine="true"
android:text="554"
android:textColor="#color/colorWhite"
android:textSize="18sp" />
</LinearLayout>
just remove android:weighSum="1" and android:layout_weight attribute in two textViews
enter code here<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:fontFamily="#font/montserrat"
android:singleLine="true"
android:text="3"
android:textColor="#color/colorText"
android:textSize="20sp" />
<TextView
android:id="#+id/readed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:background="#drawable/back_new"
android:fontFamily="#font/montserrat"
android:gravity="center"
android:keepScreenOn="true"
android:paddingHorizontal="5dp"
android:paddingVertical="3dp"
android:singleLine="true"
android:text="554"
android:textColor="#color/colorWhite"
android:textSize="18sp" />
</LinearLayout>

Insert ScrollView into layout

i'm tring to add a ScrollView to this layout but when i add it the Button is positioned over the last EditText and i don't understand why. Anyone can help me to understand why and how can i fix? thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/titolo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Titolo"/>
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/titolo"
android:layout_alignStart="#+id/titolo"
android:layout_below="#+id/titolo"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:ems="10"/>
<TextView
android:id="#+id/album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/editText1"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Album"/>
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/album"
android:layout_alignStart="#+id/album"
android:layout_below="#+id/album"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:ems="10"/>
<TextView
android:id="#+id/artista"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/editText2"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Artista"/>
<EditText
android:id="#+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/artista"
android:layout_alignStart="#+id/artista"
android:layout_below="#+id/artista"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:ems="10"/>
<TextView
android:id="#+id/genere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/editText3"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Genere"/>
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/genere"
android:layout_alignStart="#+id/genere"
android:layout_below="#+id/genere"
android:ems="5"/>
<TextView
android:id="#+id/traccia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/editText3"
android:layout_alignEnd="#+id/editText3"
android:layout_alignTop="#+id/anno"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Traccia"/>
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText5"
android:layout_alignBottom="#+id/editText5"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:ems="5"/>
<TextView
android:id="#+id/artista_album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/editText6"
android:fontFamily="sans-serif-light"
android:textSize="20sp"
android:text="Artista album"/>
<EditText
android:id="#+id/editText7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/artista_album"
android:layout_alignStart="#+id/artista_album"
android:layout_below="#+id/artista_album"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:ems="5"/>
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fontFamily="sans-serif-light"
android:background="?android:selectableItemBackground"
android:text="Salva"/>
<TextView
android:id="#+id/anno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText4"
android:layout_centerHorizontal="true"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/editText4"
android:layout_toEndOf="#+id/editText4"
android:fontFamily="sans-serif-light"
android:text="Anno"
android:textSize="20sp"/>
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/anno"
android:layout_alignStart="#+id/anno"
android:layout_below="#+id/anno"
android:layout_centerHorizontal="true"
android:ems="4"/>
</RelativeLayout>
</FrameLayout>
add this line
android:layout_below="#+id/editText5"
in here.
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fontFamily="sans-serif-light"
android:background="?android:selectableItemBackground"
android:text="Salva"/>

Preventing TextView and ImageView Overlap In Relative Layout

I have a textView (titleTv) and an imageView (buyButton) which are sometimes have an overlap if the titleTv has a somewhat long name.
How might this be prevented? I understand this can be done using an external library - but it seems strange there isn't a simple way to accomplish this.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="7dip"
android:paddingTop="7dip" >
<TextView
android:id="#+id/titleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:paddingLeft="5dp"
android:text=""
android:textSize="20sp" />
<TextView
android:id="#+id/uploaderTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:paddingLeft="5dip"
android:paddingTop="5dp"
android:textColor="#color/verylightgrey"
android:textSize="16sp" />
<TextView
android:id="#+id/viewCountTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:layout_toRightOf="#id/uploaderTv"
android:paddingTop="5dp"
android:textColor="#android:color/black"
android:textSize="16sp" />
<ImageView
android:id="#+id/buyButton"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:paddingTop="7dip"
android:src="#drawable/buy_a_up_btn" />
</RelativeLayout>
Example:
(the overlapping fields are the video's title and the $ button)
http://i.stack.imgur.com/clpNv.png
just add your ImageView below that TextView. Add this attribute in your ImageView declaration
android:layout_below="#+id/titleTv"
Now the xml should be like this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="7dip"
android:paddingTop="7dip" >
<TextView
android:id="#+id/titleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:paddingLeft="5dp"
android:text=""
android:textSize="20sp" />
<TextView
android:id="#+id/uploaderTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:paddingLeft="5dip"
android:paddingTop="5dp"
android:textColor="#color/verylightgrey"
android:textSize="16sp" />
<TextView
android:id="#+id/viewCountTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:layout_toRightOf="#id/uploaderTv"
android:paddingTop="5dp"
android:textColor="#android:color/black"
android:textSize="16sp" />
<ImageView
android:id="#+id/buyButton"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_below="#+id/titleTv"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:paddingTop="7dip"
android:src="#drawable/buy_a_up_btn" />
</RelativeLayout>
Try this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="7dip"
android:paddingTop="7dip" >
<ImageView
android:id="#+id/buyButton"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:paddingTop="7dip"
android:src="#drawable/buy_a_up_btn" />
<TextView
android:id="#+id/titleTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/buyButton"
android:background="#color/white"
android:paddingLeft="5dp"
android:text=""
android:textSize="20sp" />
<TextView
android:id="#+id/uploaderTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:paddingLeft="5dip"
android:paddingTop="5dp"
android:textColor="#color/verylightgrey"
android:textSize="16sp" />
<TextView
android:id="#+id/viewCountTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleTv"
android:layout_toRightOf="#id/uploaderTv"
android:paddingTop="5dp"
android:textColor="#android:color/black"
android:textSize="16sp" />
</RelativeLayout>

how to set a title and gap between paragraphs?

I want to rewrite an existing view to look like this:
This is my current xml and screenshot:
I'm using this 9 patch:
<!--
========================================================================
* Information layout - contains the explanation text on the background
========================================================================
-->
<RelativeLayout
android:id="#+id/layout_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/widget_bg_info1"
android:orientation="vertical" >
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="#string/widget_nodata_title"
android:textColor="#color/solid_white"
android:textSize="22sp"
android:layout_above="#+id/widget_error"
android:paddingBottom="20dp"/>
<ImageView
android:id="#+id/widget_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#drawable/widget_error"
android:layout_centerHorizontal="true" />
<LinearLayout
android:id="#+id/layout_text_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/text_info1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="87dp"
android:gravity="left"
android:paddingLeft="18dp"
android:paddingRight="15dp"
android:text="#string/widget_nodata_info1"
android:textColor="#color/solid_black"
android:textSize="15sp" />
<TextView
android:id="#+id/text_info2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="10dp"
android:gravity="left"
android:paddingLeft="18dp"
android:paddingRight="15dp"
android:text="#string/widget_nodata_info2"
android:textColor="#color/solid_black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text_info3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="10dp"
android:gravity="left"
android:paddingLeft="18dp"
android:paddingRight="15dp"
android:text="#string/widget_nodata_info3"
android:textColor="#color/solid_black"
android:textSize="15sp" />
</LinearLayout>
<!--
========================================================================
* Buttons layout - contains all the texts
========================================================================
-->
<LinearLayout
android:id="#+id/layout_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:layout_below="#+id/layout_text_info"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingTop="20dp">
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:background="#drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/text_btn_enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/widget_no_data_accept"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="#drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/text_btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/widget_no_data_close"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</RelativeLayout> <!-- -->
How pose the title on top the gray top area?
How to center the two bottom buttons?
This will fix your button layout to the bottom and center them as you want. If you can be more clear I can help you about the house image and title as well. (about the id names).
<LinearLayout
android:id="#+id/layout_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:background="#drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/text_btn_enter"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:text="#string/widget_no_data_accept"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="#drawable/button_blue"
android:clickable="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/text_btn_close"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_height="wrap_content"
android:text="#string/widget_no_data_close"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
If this is your imageview for the house picture, then it is fixed as well. Just give top margin as much as your want.
<ImageView
android:id="#+id/widget_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/text_title"
android:gravity="center"
android:src="#drawable/widget_error" />

Categories

Resources