私はナビゲーションフラグメントを作成しています。常に存在するボタン(メインボタン)と動的に追加および削除されるボタンがあります。膨らんだボタンの幅と高さが間違っています
私はボタンを膨らませたxmlリソースファイルを持っています。アイコンを変更してフラグメントルートレイアウトに追加します。
ボタンサイズを除いてほとんどすべてが機能します。後のボタンサイズは0です(getWidth()/ getHeight())。
button_navigation.xml
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigation_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/icon_test"
android:backgroundTint="@drawable/selector_bar_button"></Button>
膨張コード
Button butt = (Button) inflater.inflate(R.layout.button_navigation, null, false);
buttons.add(butt);
root_view.addView(butt);
作成インフレータ
public void setParent(MainActivity activity){
parent = activity;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
個の変数
MainActivity parent;
LayoutInflater inflater;
int index;
ArrayList<Button> buttons;
Button button_main;
LinearLayout root_view;
メインボタンは、button_navigation.xmlとして正確なコードを有しており、断片のレイアウトファイルに起こります。メインボタンのサイズは良いです。
作品をそれをしないしたいのですが、[OK]をthatsの。 –
同様の問題を抱えている人は誰でも、私はインフレータでライナーレイアウトを取得し、そのIDを介してボタンを取得し、ライナーレイアウトからそのボタンを削除して、 –