0

私のmain.xmlには、Google Nowカードのようなスタイルの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>"));

どうすればできますか?

4

0 に答える 0