Java Android使用的XML来自另一个项目,按钮图标现在看起来很小
所以我通过XML为一个测试项目创建了一个简单的接口,我有一个完全支持BLE的项目,我需要将这个接口引入其中。所以我将XML复制到这个项目中,但由于某种原因,我的按钮图标看起来非常小。我尝试用值设置高度和宽度,但大小没有改变。我确信我可以以更好的方式设置这些图像按钮,但我不明白为什么这两个项目中的相同代码看起来不同。 我已经在下面添加了我的XML代码,非常感谢您的帮助!以下是我看到的:Java Android使用的XML来自另一个项目,按钮图标现在看起来很小,java,android,xml,android-studio,android-layout,Java,Android,Xml,Android Studio,Android Layout,所以我通过XML为一个测试项目创建了一个简单的接口,我有一个完全支持BLE的项目,我需要将这个接口引入其中。所以我将XML复制到这个项目中,但由于某种原因,我的按钮图标看起来非常小。我尝试用值设置高度和宽度,但大小没有改变。我确信我可以以更好的方式设置这些图像按钮,但我不明白为什么这两个项目中的相同代码看起来不同。 我已经在下面添加了我的XML代码,非常感谢您的帮助!以下是我看到的: ``` 对于这种情况,不建议使用Hi drawable。您不能自定义大小。您可以将Button和Image
```
对于这种情况,不建议使用Hi drawable。您不能自定义大小。您可以将Button和ImageView分组,或者使用MaterialButton的1.3 alpha版本两个项目中是否有相同的styles.xml?我还将样式从项目1复制到了项目2。好的,我可以对此进行研究,但这并不能解释为什么它在案例1中有效,而相同的代码在案例2中无效?
<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>```