我正在製作一個android
版本的應用程序,基於iOS
之一,但是,我在製作頂部導航欄時遇到了麻煩。我實際上想創建一個類似於iOS
界面的操作欄,但是,我不能添加close button
,go back button
和next button
。帶按鈕和標題的頂部導航欄
首先,如果是家庭活動,頂部導航欄將包含居中標題和用於關閉當前活動的close button
。如下圖所示:
然後,如果用戶已經有了一個正確答案(或在某些條件下),然後next button
會顯示出來,如果沒有,也不會顯示出來。
就像上面的圖片,在圖片1,用戶可以回到Q1,爲Q1已經是正確的。此外,Q2也是正確的,因爲它可以進入Q3。然後,在圖2中,Q3尚未回答,但不能進入Q4,但可以進入Q2。而且,如果去Q2,圖片1的相同界面將顯示(仍然包含了下,和後退按鈕。
我現在有一個操作欄,但不能做任何事情,但只有一個標題。
的Manifest.xml:
<activity
android:name=".Problems"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenLayout|uiMode|
screenSize|smallestScreenSize"
android:theme="@style/AccountSetting"
android:label="Problems" />
toolbarlayout.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/chtl_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/chtl_useIMG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="20dp"
android:src="@mipmap/ic_launcher"
android:visibility="visible" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nilu" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nilu" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nilu" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
abs_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textColor="#000000"
android:id="@+id/mytext"
android:textSize="15sp" />
</LinearLayout>
Main.java
public class Problems extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toolbar toolbar = (Toolbar) findViewById(R.id.chtl_toolbar);
setSupportActionBar(toolbar);
}
}
Style.xml
<style name="AccountSetting" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">#ffffff</item>
<item name="colorPrimary">#ffffff</item>
</style>
它不工作,能你給更多的細節LS? – androidnewbie
@androidnewbie can you explain more –
只需將'Toolbar'追加到我的'.xml'文件中,或者創建一個新的? – androidnewbie