julianstogs
julianstogs

Reputation: 13

Android - Used XML from another project, button icons now look TINY

So I had created a simple interface via XML for a test project, I have a full BLE-supported project that I need to bring this interface into. so I copied the XML to this project but now for some reason my button icons are appearing super small. I tried setting the height and width with values but the size does not change. I'm sure I could be setting these image buttons in a better fashion, but I just don't get why the same code looks different between these two projects. I have added my XML code below, any help is appreciated! Here's what I'm seeing: Heres the XML appearance from original project:

XML appearance in new project (same exact file/code):

  <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/lightGray2"
   tools:openDrawer="start">

   <LinearLayout
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:layout_margin="2dp"
       android:backgroundTint="#2a2a2a"
       android:orientation="vertical"
       android:padding="10dp"
       android:weightSum="1">

       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_margin="2dp"
           android:layout_weight="0.25"
           android:background="@drawable/rounded_corner"
           android:backgroundTint="@color/darkGray"
           android:orientation="vertical"
           android:weightSum="1.0">

           <TextView
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layout_marginTop="2dp"
               android:layout_weight="0.9"
               android:fontFamily="sans-serif-thin"
               android:gravity="center_horizontal"
               android:text="PROXIMITY TUNER"
               android:textColor="@color/white" />

           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layout_weight="0.1"
               android:weightSum="1.2">

               <Button
                   android:id="@+id/ButtonChannel"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_gravity="center_vertical"
                   android:layout_weight="0.4"
                   android:background="@null"
                   android:backgroundTint="@color/darkGray"
                   android:drawableTop="@drawable/radio_waves50"
                   android:fontFamily="sans-serif-thin"
                   android:includeFontPadding="false"
                   android:onClick="onButtonChannelClick"
                   android:text="channel"
                   android:textColor="@color/white" />

               <Button
                   android:id="@+id/ButtonTXPower"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_gravity="center_vertical"
                   android:layout_weight="0.4"
                   android:background="@null"
                   android:backgroundTint="@color/darkGray"
                   android:cropToPadding="false"
                   android:drawableTop="@drawable/radio_tower50"
                   android:fontFamily="sans-serif-thin"
                   android:onClick="onButtonTXPowerClick"
                   android:text="TX POWER"
                   android:textColor="@color/white" />

               <Button
                   android:id="@+id/ButtonWakeRate"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_gravity="center_vertical"
                   android:layout_weight="0.4"
                   android:background="@null"
                   android:backgroundTint="@color/darkGray"
                   android:cropToPadding="false"
                   android:drawableTop="@drawable/sample_rate_50_1"
                   android:fontFamily="sans-serif-thin"
                   android:onClick="onButtonWakeRateClick"
                   android:text="channel"
                   android:textColor="@color/white" />
           </LinearLayout>

       </LinearLayout>

       <androidx.cardview.widget.CardView
           android:id="@+id/CurrentProximityCard"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_margin="2dp"
           android:layout_weight="0.25"
           android:background="@drawable/rounded_corner"
           android:backgroundTint="@color/darkGray"
           android:gravity="center"
           android:shadowColor="@color/black"
           android:shadowDx="7"
           android:shadowDy="7"
           android:shadowRadius="5"
           app:cardCornerRadius="20dp"
           app:cardElevation="15dp">

           <RelativeLayout
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:background="@drawable/rounded_corner"
               android:backgroundTint="@color/darkGray">

               <TextView
                   android:id="@+id/FobProximityField"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_centerHorizontal="true"
                   android:layout_centerVertical="true"
                   android:fontFamily="sans-serif-thin"
                   android:text="@string/proximityStatus3"
                   android:textColor="@color/systemGreenIOS"
                   android:textSize="35dp" />

               <TextView
                   android:id="@+id/FobProxTitle"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignParentBottom="true"
                   android:layout_centerInParent="true"
                   android:layout_centerHorizontal="true"
                   android:layout_marginBottom="2dp"
                   android:fontFamily="sans-serif-thin"
                   android:text="CURRENT FOB PROXIMITY"
                   android:textAlignment="center"
                   android:textColor="@color/white" />
           </RelativeLayout>
       </androidx.cardview.widget.CardView>

       <androidx.cardview.widget.CardView
           android:id="@+id/EngineDataCard"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_margin="2dp"
           android:layout_weight="0.25"
           android:backgroundTint="@color/darkGray"
           android:gravity="center"
           android:shadowColor="@color/black"
           android:shadowDx="7"
           android:shadowDy="7"
           android:shadowRadius="5"
           app:cardCornerRadius="20dp"
           app:cardElevation="15dp">

           <RelativeLayout
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:background="@drawable/rounded_corner"
               android:backgroundTint="@color/darkGray">

               <TextView
                   android:id="@+id/EngineDataField"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_centerHorizontal="true"
                   android:layout_centerVertical="true"
                   android:fontFamily="sans-serif-thin"
                   android:text="7450 RPM"
                   android:textColor="@color/systemRedIOS"
                   android:textSize="40dp" />

               <TextView
                   android:id="@+id/EngineDataTitle"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignParentBottom="true"
                   android:layout_centerInParent="true"
                   android:layout_centerHorizontal="true"
                   android:layout_marginBottom="2dp"
                   android:fontFamily="sans-serif-thin"
                   android:text="ENGINE DATA"
                   android:textAlignment="center"
                   android:textColor="@color/white" />
           </RelativeLayout>
       </androidx.cardview.widget.CardView>

       <LinearLayout
           android:id="@+id/relative_layout1"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_margin="2dp"
           android:layout_marginBottom="8dp"
           android:layout_weight="0.25"
           android:backgroundTint="#4c4c4c"
           android:gravity="bottom"
           android:weightSum="1">

           <androidx.cardview.widget.CardView
               android:id="@+id/FobBatteryCard"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layout_alignParentLeft="true"
               android:layout_marginRight="2dp"
               android:layout_weight="0.5"
               android:background="@drawable/rounded_corner"
               android:backgroundTint="@color/darkGray"
               android:gravity="center"
               android:shadowColor="@color/black"
               android:shadowDx="7"
               android:shadowDy="7"
               android:shadowRadius="5"
               android:text="12121212"
               app:cardCornerRadius="20dp"
               app:cardElevation="15dp">

               <RelativeLayout
                   android:layout_width="match_parent"
                   android:layout_height="match_parent">

                   <TextView
                       android:id="@+id/FobBatteryField"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_centerHorizontal="true"
                       android:layout_centerVertical="true"
                       android:fontFamily="sans-serif-thin"
                       android:text="4.9V"
                       android:textColor="@color/systemGreenIOS"
                       android:textSize="40dp" />

                   <TextView
                       android:id="@+id/FobBatteryTitle"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_alignParentBottom="true"
                       android:layout_centerInParent="true"
                       android:layout_centerHorizontal="true"
                       android:layout_marginBottom="2dp"
                       android:fontFamily="sans-serif-thin"
                       android:text="FOB BATTERY"
                       android:textAlignment="center"
                       android:textColor="@color/white" />
               </RelativeLayout>
           </androidx.cardview.widget.CardView>

           <androidx.cardview.widget.CardView
               android:id="@+id/CurrentChannelCard"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layout_alignParentRight="true"
               android:layout_marginLeft="2dp"
               android:layout_weight="0.5"
               android:background="@drawable/rounded_corner"
               android:backgroundTint="@color/darkGray"
               android:gravity="center"
               android:shadowColor="@color/black"
               android:shadowDx="7"
               android:shadowDy="7"
               android:shadowRadius="5"
               android:text="32323232"
               app:cardCornerRadius="20dp"
               app:cardElevation="15dp">

               <RelativeLayout
                   android:layout_width="match_parent"
                   android:layout_height="match_parent">

                   <TextView
                       android:id="@+id/CurrentChannelField"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_centerHorizontal="true"
                       android:layout_centerVertical="true"
                       android:fontFamily="sans-serif-thin"
                       android:text="@string/channelStatus"
                       android:textColor="@color/systemGreenIOS"
                       android:textSize="40dp" />

                   <TextView
                       android:id="@+id/channelTitle"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_alignParentBottom="true"
                       android:layout_centerInParent="true"
                       android:layout_centerHorizontal="true"
                       android:layout_marginBottom="2dp"
                       android:fontFamily="sans-serif-thin"
                       android:text="CHANNEL"
                       android:textAlignment="center"
                       android:textColor="@color/white" />
               </RelativeLayout>
           </androidx.cardview.widget.CardView>

       </LinearLayout>
   </LinearLayout>

   </RelativeLayout>```

Upvotes: 0

Views: 41

Answers (1)

Rustam Samandarov
Rustam Samandarov

Reputation: 892

Hi drawable is not recommended for this kind of situation. You cannot customize size. You can group Button and ImageView or use 1.3 alpha version of MaterialButton

Upvotes: 1

Related Questions