【问题标题】:Button color don't show on real device/image not filling background按钮颜色不显示在真实设备上/图像不填充背景
【发布时间】:2016-02-12 10:31:24
【问题描述】:

我正在创建一个 Android 应用程序,并使用 backgroundTint #fed136 创建了按钮,但问题是它们在我的真实设备上没有那种颜色。但是,有背景,我相信他们有,但是按钮没有那些圆角。另外,我希望某个图像可以填充按钮下方的整个屏幕,但它有点卡住了,左右边缘没有被填充,手机的底部也没有。另外,它也没有显示在我的屏幕上。

上面是应该的,下面是它的样子..我的意思是这是怎么发生的?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:clickable="false"
android:background="#222">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="About"
    android:id="@+id/button"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:backgroundTint="#fed136" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Portfolio"
    android:id="@+id/button3"
    android:layout_alignBottom="@+id/button"
    android:layout_centerHorizontal="true"
    android:backgroundTint="#fed136" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Contact"
    android:id="@+id/button4"
    android:layout_alignBottom="@+id/button3"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:backgroundTint="#fed136" />

 <ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView"
    android:layout_below="@+id/button3"
    android:scaleType="fitXY"
    android:src="@drawable/header" />

   </RelativeLayout>

【问题讨论】:

  • 你能提供你的布局文件吗?
  • @MariusKaunietis 已添加!
  • 移除RelativeLayout的内边距,让你的图片覆盖整个布局。还将 scaleType 更改为 fitXY。对于另一个问题,您应该使用背景属性为其赋予颜色,而不是背景色。我不明白圆角的问题,您没有使用自定义样式或任何东西作为您的背景,那么这将如何改变?
  • 您应该为圆角制作一个可绘制对象并将其设置为按钮的背景,并且我尝试了您的代码,因为您的期望只有按钮没有圆形,因为您必须制作一个可绘制对象
  • 看看stackoverflow.com/questions/27735890/…这可能是你问题的原因

标签: android android-layout android-activity android-studio imageview


【解决方案1】:

使用

android:background="#fed136"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-19
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多