Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 文本视图优于图像视图?_Java_Android_Textview_Batterylevel - Fatal编程技术网

Java 文本视图优于图像视图?

Java 文本视图优于图像视图?,java,android,textview,batterylevel,Java,Android,Textview,Batterylevel,在main.xml中,我有一个类似GoogleNow卡的Imageview。每次电池更换百分比时,此图像视图都会更改图像。我还有一个文本视图,我在其中写入电池电量。我想要的是将电池电量写在imageview上,这样我就可以在电池图像附近看到它。这是main.xml部分: <ImageView android:id="@+id/textViewBatteryInfoimage" (this change with percentage) android:layout_widt

在main.xml中,我有一个类似GoogleNow卡的Imageview。每次电池更换百分比时,此图像视图都会更改图像。我还有一个文本视图,我在其中写入电池电量。我想要的是将电池电量写在imageview上,这样我就可以在电池图像附近看到它。这是main.xml部分:

<ImageView
    android:id="@+id/textViewBatteryInfoimage" (this change with percentage)
    android:layout_width="160dp"
    android:layout_height="160dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:adjustViewBounds="true"
    android:contentDescription="image"
    android:background="@layout/background_card"
        tools:ignore="HardcodedText" />
<TextView
    android:id="@+id/level"         
    android:gravity="center_vertical"
    android:paddingLeft="10dp"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:fontFamily="sans-serif-light"
    android:layout_marginTop="5dp"
    android:textColor="#FB8A34"
    android:textSize="20dp"
    tools:ignore="SelectableText,SpUsage" />

电池电量由java编写

TextView textViewliv = (TextView)findViewById(R.id.level);
            textViewliv.setText(Html.fromHtml("Battery level: "+ "<small> <font color='#343434'>" + level + "%</font></small>"));
TextView textViewliv=(TextView)findViewById(R.id.level);
textViewliv.setText(Html.fromHtml(“电池电量:“+”+电量+“%”);

我该怎么做呢?

使用
相对布局
框架布局
@David_D Raghunandan的评论是一个建议,而不是一个问题。你最好使用框架布局,并将TextView放在ImageView之后哦,对不起,我今天太累了:)。好的,但我不能使用其他布局,因为如果我更改布局,我的应用程序会发生很大变化。