0

I have the following presentation:

enter image description here

Here the XML

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:gravity="center"
    android:scaleType = "centerCrop"
    android:divider="@drawable/empty_tall_divider"
    android:showDividers="middle"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/inspeccion_menu_txtCantidadMensual"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="0"
        android:textAlignment="center"
        android:textSize="25pt" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Inspecciones realizadas este mes"
        android:textAlignment="center"
        android:textSize="10pt" />

    <Button
        android:id="@+id/inspeccion_botiquin_menu_btnHistorial"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#fff"
        android:text="VER HISTORIAL" />

    <LinearLayout
        android:id="@+id/inspeccion_menu_btnIniciar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/btn_default"
        android:clickable="true"
        android:divider="@drawable/empty_middle_divider"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="6pt"
        android:showDividers="middle">


        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="INICIAR NUEVA INSPECCIÓN"
            android:textColor="#fff"
            android:textAppearance="?android:attr/textAppearanceButton"></TextView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_marginBottom="10px"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/inspeccion_menu_imgIcono"
                android:layout_width="match_parent"
                android:layout_height="30pt"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_weight="2"
                android:src="@mipmap/ic_menu_botiquin"></ImageView>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:divider="@drawable/empty_small_divider"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Fecha de Inspección"
                    android:textColor="#eee" />

                <TextView
                    android:id="@+id/inspeccion_menu_txtFecha"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="10-10-2017"
                    android:textColor="#fff"
                    android:textSize="8pt" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Inspector"
                    android:textColor="#eee" />

                <TextView
                    android:id="@+id/inspeccion_menu_txtInspector"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Zavala Salinas Julio Ramiro"
                    android:textColor="#fff"
                    android:textSize="8pt" />

            </LinearLayout>

        </LinearLayout>

    </LinearLayout>

</LinearLayout>

The first button is a simple button without drastic changes.

The second one it's a frankeinstein, it's not a button but a LinearLayout with nested components mimicking a button.

I ended up using android:background="@android:drawable/btn_default"to make it look as close as possible like a button. But it's really awful, i've been looking at https://developer.android.com/guide/topics/ui/controls/button.htmlbut it doesn't really works on this.

It doesn't properly emulate the click animation, and the pressed color get's messed up sometimes.

Also, the color needs to be overwriten on the run, i've been using this and works great with simple button and custom layout.

btnHistorial.getBackground().setColorFilter(Color.parseColor("#EA4335"), PorterDuff.Mode.MULTIPLY);
btnIniciar.getBackground().setColorFilter(Color.parseColor("#EA4335"), PorterDuff.Mode.MULTIPLY);
Wesos de Queso
  • 1,526
  • 1
  • 21
  • 23

0 Answers0