我想我的问题很简单,所以谢谢你的帮助。我做了一个简单的游戏,终于运行了,但我不能让开始内容显示在页面的中心,谁能帮我解决这个问题?
这是当前页面:
请进入此处查看渲染 代码:
资源/布局/activity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:background="@color/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="25sp"
android:textColor="#7ba6df"
android:text="@string/activity_main_title"/>
<Button
android:id="@+id/continue_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/continue_lable"/>
<Button
android:id="@+id/new_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/new_game_lable"/>
<Button
android:id="@+id/about_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/about_lable"/>
<Button
android:id="@+id/exit_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/exit_lable"/>
</LinearLayout>
</LinearLayout>
res/values/string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="activity_main_title">android sudoku</string>
<string name="continue_lable">开始游戏</string>
<string name="about_lable">游戏说明</string>
<string name="new_game_lable">是否开启音乐</string>
<string name="exit_lable">退出游戏</string>
</resources>
Mainactivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}