Picture not aligning top? - android

So in my program i have a layout implemented in which i want the image to alignTop of the parent. I used to exact same layout code for another activity (with minor changes) and it works perfectly but when using it in this activity it does not. My image still aligns to the center fo the view. Here is the layout xml
<?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:background="#color/darkGray"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.intellidev.fuzionvapor.HomeDetails"
tools:showIn="#layout/activity_home_details">
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:scaleType="fitCenter" />
<TextView
android:id="#+id/homeDetailsActivityTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/homeDetailsActivityImage"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/homeDetailsActivityPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/homeDetailsActivityImage"
android:textColor="#color/fuzionRed"
android:textSize="20sp"
android:textStyle="bold" />
<View
android:id="#+id/homeDetailsActivityRuler"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="#+id/homeDetailsActivityTitle"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#color/white" />
<TextView
android:id="#+id/homeDetailsActivityDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/homeDetailsActivityRuler"
android:textColor="#color/white"
android:textSize="15sp" />
<LinearLayout
android:id="#+id/homeDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/homeDetailsActivityButton"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/homeDetailsActivitySizeSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="1dp"
android:layout_weight="1"
app:ms_arrowColor="#color/fuzionRed"
app:ms_arrowSize="16dp"
app:ms_baseColor="#color/fuzionRed"
app:ms_enableFloatingLabel="true"
app:ms_floatingLabelColor="#color/fuzionRed"
app:ms_floatingLabelText="#string/sizeFloatingLabel"
app:ms_highlightColor="#color/fuzionRed"
app:ms_hintColor="#color/fuzionRed"
app:ms_hint="Size"
app:ms_multiline="false"
app:ms_thickness="1dp" />
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/homeDetailsActivityNicotineSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
app:ms_arrowColor="#color/fuzionRed"
app:ms_arrowSize="16dp"
app:ms_baseColor="#color/fuzionRed"
app:ms_enableFloatingLabel="true"
app:ms_floatingLabelColor="#color/fuzionRed"
app:ms_floatingLabelText="#string/nicotineFloatingLabel"
app:ms_highlightColor="#color/fuzionRed"
app:ms_hintColor="#color/fuzionRed"
app:ms_multiline="false"
app:ms_hint="Nicotine"
app:ms_thickness="1dp" />
</LinearLayout>
<Button
android:id="#+id/homeDetailsActivityButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#color/fuzionRed"
android:text="Add To Cart"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>

change
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:scaleType="fitCenter" />
to
<ImageView
android:id="#+id/homeDetailsActivityImage"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:adjustViewBounds="true"
android:scaleType="fitStart" />

Related

Android XML Insert a layout on another layout

I am developing a screen that allows the user to create a post:
here
I want that when the user clicks on the cardview of the plus, a relative layout opens that through a recyclerview shows the various types of films, and the same thing for the other cardview with the genres of films. I don't know how to insert a layout into another layout and then use your own objects. What should I do, create an overlapping layout or do something else? I can't superimpose another layout on mine,
beacuse this happens
As you can see the related layout is below the main cardview. How could I put it on top?
Full Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".userProfile">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="-37dp"
android:backgroundTint="#EFE8AB"
app:cardCornerRadius="40dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtVal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Valutazione"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="230dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<androidx.cardview.widget.CardView
android:id="#+id/imBackReg"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="25dp"
android:layout_marginRight="8dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:backgroundTint="#color/redButton2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_close_24"
/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="295dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<EditText
android:id="#+id/txt_desc"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginRight="20dp"
android:layout_marginTop="330dp"
android:background="#color/primaryPopHome2"
android:ems="10"
android:backgroundTint="#EFE8AB"
android:gravity="top|left"
android:hint="Descrizione"
android:layout_alignStart="#+id/txtVal"
android:inputType="textMultiLine"
android:textColor="#color/black"
android:textColorHint="#b7b7b7"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="450dp"
android:layout_marginHorizontal="15dp"
android:background="#color/darkpost"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="470dp"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tipologia:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginLeft="2dp"
android:layout_centerVertical="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:text="Tipologia scelta"
android:layout_marginTop="45dp"
android:layout_marginLeft="3dp"
/>
<androidx.cardview.widget.CardView
android:id="#+id/chooseTip"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="20dp"
android:layout_marginLeft="8dp"
android:layout_toEndOf="#+id/txtT"
android:layout_centerVertical="true"
android:backgroundTint="#color/darkpost">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_add_24"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/txtC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Categoria:"
android:layout_centerVertical="true"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginLeft="10dp"
android:layout_toEndOf="#+id/chooseTip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:text="Categoria scelta"
android:layout_marginTop="45dp"
android:layout_alignStart="#id/txtC"
android:layout_marginLeft="2dp"
/>
<androidx.cardview.widget.CardView
android:id="#+id/chooseCat"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="20dp"
android:layout_marginLeft="8dp"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/txtC"
android:backgroundTint="#color/darkpost">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_add_24"/>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</HorizontalScrollView>
<EditText
android:id="#+id/txt_valuta"
android:layout_width="50dp"
android:layout_height="46dp"
android:layout_marginTop="220dp"
android:layout_marginLeft="13dp"
android:layout_centerHorizontal="true"
android:background="#drawable/textview_new_style"
android:ems="10"
android:hint="0"
android:text=""
android:textSize="25dp"
android:textAlignment="center"
android:layout_toEndOf="#+id/txtVal"
android:textColor="#color/black"
android:textColorHint="#EFE8AB"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/10"
android:textSize="25dp"
android:textColor="#color/black"
android:layout_marginTop="225dp"
android:layout_marginLeft="5dp"
android:layout_toEndOf="#+id/txt_valuta"
/>
<androidx.cardview.widget.CardView
android:id="#+id/img_imgpost"
android:layout_width="140dp"
android:layout_height="150dp"
app:cardCornerRadius="30dp"
android:layout_marginLeft="20dp"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:backgroundTint="#color/darkpost">
<ImageView
android:id="#+id/imgPostICV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#color/darkpost"/>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titolo:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="567dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<EditText
android:id="#+id/txt_titoloo"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="600dp"
android:layout_marginHorizontal="5dp"
android:backgroundTint="#color/darkpost"
android:ems="10"
android:hint="Titolo"
android:layout_marginBottom="20dp"
android:inputType="textEmailAddress"
android:textColor="#color/black"
android:textColorHint="#b7b7b7"
android:layout_alignStart="#+id/d"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/btn_invia"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="660dp"
app:cardCornerRadius="15dp"
android:layout_marginBottom="10dp"
android:layout_marginHorizontal="20dp"
android:backgroundTint="#E8E1A2"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pubblica il Post"
android:textColor="#color/black"
android:layout_centerInParent="true"
android:textSize="30dp"
android:fontFamily="#font/amiko"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"/>
</RelativeLayout>
This example could solve your problem
fragment_main.xml
<?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" >
<include
android:id="#+id/innerLayout"
layout="#layout/inner_layout" />
</RelativeLayout>
inner_layout.xml
<?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:id="top_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="inner text" />
</RelativeLayout>
Now in your MainFragment class
Depending on your need you can set the visibility of the inner_layout by using the following code snippet
View innerLayout = findViewById(R.id.innerLayout);
//For hiding the innner layout dynamically
innerLayout.top_layout.setVisibility(View.GONE);
//For showing the innner layout dynamically
innerLayout.top_layout.setVisibility(View.VISIBLE);
//to set text in TextView
innerLayout.text.setText("Anything you want");

Shadow in Android

enter image description here
As you can see there is a shadow around the ticket. I cannot make this because I am using the library (TicketView) and there is a problem with Scallops
HERE IS MY CODE
<?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=".MainActivity"
android:background="#f3f6f9">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginTop="52.5dp"
android:layout_marginEnd="18dp"
android:orientation="vertical"
android:elevation="14dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="37.5dp"
android:background="#drawable/gradient_tickets">
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:elevation="2dp"
android:text="Bus 79"
android:textColor="#fefefe"
android:textSize="12sp"
tools:layout_editor_absoluteX="37dp"
tools:layout_editor_absoluteY="69dp" />
<ImageView
android:id="#+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:scaleX="0.6"
android:scaleY="0.6"
android:src="#drawable/arrow_list" />
<TextView
android:id="#id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/text1"
android:layout_marginTop="40dp"
android:layout_marginBottom="10dp"
android:text="11/03/2017"
android:textColor="#a4158a"
android:textSize="12sp" />
<TextView
android:id="#+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/img1"
android:layout_alignParentRight="false"
android:layout_alignParentBottom="false"
android:layout_marginTop="40dp"
android:text="$0.30"
android:textColor="#a4158a"
android:textSize="12sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.vipulasri.ticketview.TicketView
android:id="#+id/ticketView"
android:layout_width="wrap_content"
android:layout_height="142dp"
app:ticketBackgroundColor="#FFFFFF"
app:ticketDividerColor="#16191c"
app:ticketDividerDashGap="4dp"
app:ticketDividerDashLength="3dp"
app:ticketDividerPadding="1.5dp"
app:ticketDividerType="dash"
app:ticketDividerWidth="0.5dp"
app:ticketOrientation="horizontal"
app:ticketScallopPositionPercent="25.7"
app:ticketScallopRadius="7dp"
app:ticketShowBorder="false"
app:ticketShowDivider="true"
/>
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20.5dp"
android:layout_marginTop="16.5dp"
android:elevation="2dp"
android:text="12/03/2017"
android:textColor="#a4158a"
android:textSize="10sp" />
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/ticketView"
android:layout_alignRight="#+id/ticketView"
android:layout_marginTop="16.5dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:elevation="2dp"
android:text="$0.30"
android:textColor="#a4158a"
android:textSize="10sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="31dp"
android:layout_marginTop="47dp"
android:layout_marginRight="31dp"
android:layout_marginBottom="45dp"
android:elevation="3dp"
android:src="#drawable/barcode_img" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
I need to have a shadow there but I cannot manage to do it. Also I used the TicketView which is for making the form of the ticket. Could u please say what I need to add there in order to have such a shadow?
You can use CardView. There is a parameter which app:cardElevation.
But if it's not possible, You can create a drawable and you can create shadow with using gradient.

RecyclerView Cutting Off in the last data in LinearLayout

I have a LinearLayout activity that contains two contents which are CardView 1 and CardView 2. Everything is doing well, also with NestedScrollView. But I have problem in the last RecycleView data, it is cutting off a little bit in very bottom.
I already tried many solution that I have searched for in Stack Overflow and this still doing bad. I'm new in this, please help
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.yehezkiel.eclassapp.MateriActivity"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_nilai"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
My Custom RecyclerView
<?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="fill_parent"
android:layout_height="90dp"
android:background="#color/white"
android:padding="10dip">
<TextView
android:id="#+id/nama_nilai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toStartOf="#+id/view_2"
android:gravity="center_vertical"
android:text="Pemrogaman Web Tugas 1"
android:textColor="#5e1b2c"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="#+id/view_2"
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="14dp"
android:layout_toStartOf="#+id/imageView10"
android:background="#c0c0c0" />
<TextView
android:id="#+id/bobot_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/imageView8"
android:textAlignment="center"
android:layout_marginTop="0.5dp"
android:ellipsize="end"
android:gravity="center"
android:text="Bobot"
android:textColor="#555555"
android:textSize="8sp" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignEnd="#+id/bobot_layout"
android:layout_below="#+id/nama_nilai"
android:layout_marginTop="8dp"
app:srcCompat="#drawable/percentage" />
<TextView
android:id="#+id/bobot_nilai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView8"
android:layout_alignTop="#+id/percent"
android:layout_marginStart="8dp"
android:layout_toEndOf="#+id/bobot_layout"
android:text="5.00" />
<TextView
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView8"
android:layout_toEndOf="#+id/bobot_nilai"
android:text="%"
android:layout_marginStart="2dp"/>
<ImageView
android:id="#+id/imageView9"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_alignBottom="#+id/percent"
android:layout_marginStart="9dp"
android:layout_toEndOf="#+id/percent"
app:srcCompat="#drawable/equality" />
<TextView
android:id="#+id/skala_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/imageView9"
android:layout_alignStart="#+id/imageView9"
android:layout_below="#+id/imageView9"
android:layout_marginTop="1dp"
android:ellipsize="end"
android:gravity="center"
android:text="Skala"
android:textAlignment="center"
android:textColor="#555555"
android:textSize="8sp" />
<TextView
android:id="#+id/skala_nilai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/skala_layout"
android:layout_marginStart="8dp"
android:layout_toEndOf="#+id/imageView9"
android:text="100.00" />
<ImageView
android:id="#+id/imageView10"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_below="#+id/nama_nilai"
android:layout_toStartOf="#+id/nilai_nilai"
app:srcCompat="#drawable/score" />
<TextView
android:id="#+id/nilai_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/imageView10"
android:layout_toStartOf="#+id/nilai_nilai"
android:ellipsize="end"
android:text="Nilai"
android:textAlignment="center"
android:textColor="#555555"
android:textSize="12sp" />
<TextView
android:id="#+id/nilai_nilai"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_alignBottom="#+id/nilai_layout"
android:layout_alignParentEnd="true"
android:layout_below="#+id/information"
android:text="89.70"
android:padding="15dp"
android:textAlignment="center"
android:textSize="18sp" />
<ImageView
android:id="#+id/information"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignEnd="#+id/nilai_nilai"
android:layout_alignParentTop="true"
app:srcCompat="#drawable/information" />
</RelativeLayout>
I don't think it's overwritten but I think the textview is hiding behind the card itself since its in a relative layout.
Can you try adding layout below attribute in your cardview and assign the ID of the textview "static1"
Let me know how it goes.

Right apportionment of layouts in relative layout - android

Hi I have problem with apportionment of layouts in android xml.
The master layout is Relative layout. Whole screen is occupied by ExoPlayer and these three elements are placed over the player.
On the picture blue is linear layout and it should take 1/3 of the screen height.
The green layout(linear) should takes 1/9 of the screen height and the red linear should also takes 1/3 of the screen.
I have tried to use weights but unfortunately my approach doesn't work and I am getting warning that could affect performance of the application.
Please, can you assist me to achieve this design?
Thanks
EDIT:
<?xml version="1.0" encoding="utf-8"?>
<data>
<import type="android.view.View" />
<import
alias="position" />
<variable
name="vm"/>
</data>
<RelativeLayout
android:id="#+id/master_layoout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="#+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:layoutMode="#{vm.fullScreen}"
android:player="#{vm.player}"
app:use_controller="false" />
<!-- STARTof menu layout-->
<LinearLayout
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="9">
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"/>
<LinearLayout
android:id="#+id/menu_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/info"
android:layout_alignParentEnd="true"
android:background="#000000"
android:orientation="vertical"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="1dp"
android:visibility="#{vm.menuVisibility}"
android:layout_weight="3">
<LinearLayout
android:id="#+id/details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#{vm.getSelectedCurrentOption == 0 ? #color/selectedMenuItem : #color/unselectedMenuItem }"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:src="#drawable/mockup_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:fontFamily="sens-serif"
android:paddingEnd="10dp"
android:text="DETALJNO"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/favorites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:background="#{vm.getSelectedCurrentOption == 1 ? #color/selectedMenuItem : #color/unselectedMenuItem }"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:src="#drawable/mockup_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:fontFamily="sens-serif"
android:text="OMILJENI"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/record"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#{vm.getSelectedCurrentOption == 2 ? #color/selectedMenuItem : #color/unselectedMenuItem }"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:src="#drawable/mockup_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:fontFamily="sens-serif"
android:text="VRATI NA POCETAK"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/remind_me"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:background="#{vm.getSelectedCurrentOption == 3 ? #color/selectedMenuItem : #color/unselectedMenuItem }"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:src="#drawable/mockup_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:fontFamily="sens-serif"
android:text="SNIMI"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/return_to_begin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#{vm.getSelectedCurrentOption == 4 ? #color/selectedMenuItem : #color/unselectedMenuItem }"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:src="#drawable/mockup_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:fontFamily="sens-serif"
android:paddingEnd="10dp"
android:text="PODSETI ME"
android:textColor="#000000" />
</LinearLayout>
<!-- end of menu layout-->
</LinearLayout>
<LinearLayout
android:id="#+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_weight="1">
<RelativeLayout
android:id="#+id/media_control_view"
android:layout_width="match_parent"
android:layout_height="58dp"
android:background="#96000000"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:visibility="#{vm.getMediaControlView==true ? View.VISIBLE : View.INVISIBLE}">
<ImageView
android:id="#+id/channel_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:src="#{vm.icon}" />
<TextView
android:id="#+id/media_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginTop="12dp"
android:layout_toEndOf="#+id/channel_icon"
android:fontFamily="sens-serif"
android:maxLength="50"
android:padding="12dp"
android:text="#{vm.getTitle}"
android:textColor="#f15a29"
android:textSize="12sp" />
<ImageView
android:id="#+id/play_pause_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toStartOf="#+id/animate_progress_bar"
android:src="#drawable/play_icon" />
<com.daasuu.ahp.AnimateHorizontalProgressBar
android:id="#+id/animate_progress_bar"
android:layout_width="300dp"
android:layout_height="2dp"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_toStartOf="#+id/remaining_time"
android:max="#{vm.maxProgress}"
android:paddingStart="10dp"
android:progress="#{vm.progress}"
app:ahp_backgroundColor="#C0C0C0"
app:ahp_progressColor="#f15a29" />
<TextView
android:id="#+id/remaining_time"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginEnd="25dp"
android:layout_marginTop="12dp"
android:layout_toStartOf="#+id/icon_info"
android:fontFamily="sens-serif"
android:padding="12dp"
android:text="#{vm.times}"
android:textColor="#D3D3D3" />
<ImageView
android:id="#+id/icon_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_toStartOf="#+id/icon_menu"
android:src="#drawable/icon_info" />
<ImageView
android:id="#+id/icon_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="5dp"
android:layout_marginStart="10dp"
android:src="#drawable/icon_menu" />
</RelativeLayout>
<LinearLayout
android:id="#+id/additional_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#80000000"
android:orientation="horizontal"
android:visibility="#{vm.infoVisibility}"
android:weightSum="90"
android:layout_weight="3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cover_image" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_weight="60"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sens-serif"
android:text="The Gardian of the Galaxy Vol.2"
android:textColor="#color/primary_orange"
android:textSize="25sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sens-serif"
android:text="19:00 - 21:00 | 2017 | Science fiction film/Action | 2h 18m\n"
android:textColor="#color/epg_event_layout_text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sens-serif"
android:text="Peter Quill and his fellow Guardians are hired by a power-\nful alien race, the Sovereign, to protect their precious bat-\nteries from invaders. When it is discovered that Rocket\nhas stolen the items they were sent to guard, the Sover-\n"
android:textColor="#color/epg_event_layout_text" />
</LinearLayout>
<View
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:background="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sens-serif"
android:text="Rezija:\nMajkl Kejn\n\nGLUMCI:\nChris Pratt, Zoe\nSaldana, Dave Bau-\ntista, Bradley\nCooper, Vin Diesel,\nMichael Rooke\n"
android:textColor="#color/epg_event_layout_text" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Layout Weight works only with LinearLayout
Use weights for your views and test them. The example given in the documentation is pretty self-explanatory.

How do I make the Android Cardview appear like Android now? (align bottom)

I am trying to make an android view where there is an image at the top, with text at the bottom, similar to the Android now cards.
I'm having issues taking the "command" buttons and aligning them below all the text, ideally separated by a HR line.
Here is the code I've been working with, and unable to make it look like the android Now cards -
<?xml version="1.0" encoding="utf-8"?>
<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_gravity="center"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp">
<LinearLayout
android:id="#+id/card_view_inner_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<TextView
android:textColor="#0000FF"
android:id="#+id/personaTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/image_view"
android:layout_toStartOf="#+id/image_view"
android:textAppearance="?android:textAppearanceLarge"
android:text="Some text here" />
<TextView
android:textColor="#00FFFF"
android:id="#+id/personaTextView2"
android:layout_below="#+id/personaTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/image_view"
android:layout_toStartOf="#+id/image_view"
android:text="Some text here" />
<ImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#android:drawable/btn_radio" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray" />
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/cardAction1"
android:textColor="#00FFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Action 1"
android:layout_toLeftOf="#+id/cardAction2"
style="?android:attr/borderlessButtonStyle"
/>
<Button
android:id="#+id/cardAction2"
android:textColor="#00FFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Action 2"
style="?android:attr/borderlessButtonStyle"
/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
The problem I'm (now) having is that I can't get the action buttons to work
You have to add a flat button like this in your view (see this link):
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Your text"
style="?android:attr/borderlessButtonStyle"
/>
Then, of course, is up to you to design your View.
Something like this?
<?xml version="1.0" encoding="utf-8"?>
<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_gravity="center"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp">
<LinearLayout
android:id="#+id/card_view_inner_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/text_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/image_view"
android:layout_toStartOf="#+id/image_view"
android:textAppearance="?android:textAppearanceLarge"
android:text="Some text here" />
<TextView
android:id="#+id/text_view2"
android:layout_below="#+id/text_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/image_view"
android:layout_toStartOf="#+id/image_view"
android:text="Some text here" />
<ImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#android:drawable/btn_radio" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Some random text" />
</LinearLayout>
</android.support.v7.widget.CardView>

Categories

Resources