0
私は、ユーザーの入力に基づいて変化する5つの列を持つ動的棒グラフを作成しようとしています。私はそうのような長方形のXML描画可能形状を定義した:高さを変更せずに長方形の幅を変更する方法
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp"
/>
<solid
android:color="#c73434"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="270dp"
android:height="60dp"
/>
<stroke android:width="2px"
color="#ff00ffff" />
</shape>
私はこのように私のXMLレイアウトファイルのバー形状を5回埋め込んだ:
<ImageView
android:id="@+id/bar_1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="start"
android:src="@drawable/bar"/>
<ImageView
android:id="@+id/bar_2"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="start"
android:src="@drawable/bar"/>
etc...
私は幅を変更できるようにしたいですユーザーの入力に基づいてバーのサイズを調整しますが、ImageViewの「幅」プロパティを調整すると、高さにも比例します(バー全体が小さくなります)。助言がありますか?これを行うより良い方法はありますか?
#2働いた - ありがとう!大きさの制約が物事を所定の場所に固定していることに気付かなかった。 – NBC
ニース!あなたは答えとしてマークすることができます!私は自分自身を確信していませんでしたが、拘束する気持ちがありました。 – daxgirl