グラフィックレイアウト上に、上の中央ボタンを表示します。 私のエミュレータのマイボタンは左上隅にあります。エミュレータのグラフィックレイアウトが異なります
私のxmlファイル:また
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mairie01"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/decourvrir1" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/schedule" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/decouvrir2" />
</LinearLayout>
: を私は他のレイアウトを使用することは不可能ボタン、をクリックしてください。 グラフィックレイアウトは問題ありませんが、私のエミュレータでは、線レイアウトとボタンの背景がありません。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mairie01">
<Button
android:id="@+id/manger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/eat" />"
<Button
android:id="@+id/dormir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/autres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
私の下手な英語のため申し訳ありませんが:xmlファイルを関連付け
。
はい私は正しいレイアウトを設定しました。私のxmlファイルは、main.xmlです。\ [コード] public class mainアクティビティ{ /**アクティビティが最初に作成されたときに呼び出されます。 */ @Override パブリックボイドonCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); [/ code] 私はプログラムで試してみますが、私のループの後にボタンにアクセスする(setTextをexempleにする)方法は? – Stan
私の主な活動はこれで大丈夫です: LinearLayout m_layout = new LinearLayout(this); \t \t \t \t \t \t \t m_layout.addView(viePratique); \t \t \t \t \t \t \t m_layout.addView(decouvrir); \t \t \t \t \t \t \t m_layout.addView(agenda); \t \t \t \t \t \t \t m_layout.setBackgroundResource(R.drawable.mairie01); \t \t \t \t \t \t \t m_layout.setHorizontalGravity(1); \t \t \t \t \t \t \t setContentView(m_layout); – Stan