2017-09-08 113 views
0

我在一箇舊的Android項目上工作,我使用了一個compileSdkVersion 16.我在下拉菜單中放置了一個SeekBar(滑塊)。它完美的工作,但我的按鈕,用於顯示下拉菜單是在左邊,我想它在右邊,就像導航抽屜活動(垂直3點)中的參數按鈕。將下拉菜單右移

在我的主要活動我有thise:

ActionBar actionBar = getActionBar(); 
DropDown dropDown = new DropDown(this,"Controls","Power", "Tag Filter"); 
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); 
actionBar.setListNavigationCallbacks(dropDown, this); 

我用兩個佈局,一個用於操作欄中的按鈕:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="end"> 

    <TextView android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:text="Controls" 
     android:textColor="#FFFFFF" 
     android:textSize="20sp" /> 
</LinearLayout> 

的另一個用於我的下拉菜單:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/seekBarTextView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="15dp" 
      android:layout_marginTop="15dp" 
      android:text="TextView" 
      android:textColor="#FFFFFF" /> 

     <SeekBar 
      android:id="@+id/seekBar" 
      android:layout_width="250dp" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="11dp" 
      android:layout_toRightOf="@+id/seekBarTextView" 
      android:layout_weight="1" /> 

    </LinearLayout> 
[...] 
</RelativeLayout> 

我不知道如何將我的按鈕放在右邊,實際上它在左邊,靠近應用程序名稱和我想把它放在相反的地方。 我有這樣的: enter image description here 但我想這一點: enter image description here

編輯: 我gradle這個文件:

apply plugin: 'com.android.application' 

def AAVersion = "4.3.0" // change this to your desired version, for example the latest stable: 4.2.0 

android { 
    compileSdkVersion 16 
    buildToolsVersion '25.0.0' 
    //buildToolsVersion '25.3.1' 

    defaultConfig { 
     applicationId "com.company.dpdencoder.uhu" 
     minSdkVersion 14 
     targetSdkVersion 15 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

dependencies { 
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion" 
    compile "org.androidannotations:androidannotations-api:$AAVersion" 
    compile 'com.android.support:support-v4:18.0.0' 
    compile 'com.google.guava:guava:15.0' 
    compile files('libs/jdom.jar') 
    // For Hexa coding/décoding 
    compile 'commons-codec:commons-codec:1.10' 
    compile files('libs/OpenApi_1.1.2.61_Common.jar') 
    compile files('libs/OpenApi_1.1.2.61_IaM.jar') 
    compile files('libs/OpenApi_1.1.2.61_IoT.jar') 
} 
+0

不能添加一個相對佈局,把內外?然後對齊它們 –

回答

0

工具欄動作條的高級版本。使用工具欄而不是ActionBar。 根據需要自定義工具欄。並將其設置爲ActionBar。

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); 
    setSupportActionBar(myToolbar); 

不要忘記使用Theme.AppCompat.Light.NoActionBar主題作爲您的活動主題。

約工具欄更多信息:https://developer.android.com/reference/android/widget/Toolbar.html

+0

它不存在於sdk 25和buildToolsVersion 25.我使用compile'c​​om.android.support:support-v4:18.0.0' – Fred37b

+0

使用com.android.support:appcompat-v7。你會得到的。 –

+0

我把編譯com.android.support:appcompat-v7:26.0.2'在我的依賴關係,但我有以下消息錯誤:(26,13)未能解決:com.android.support:appcompat-v7:26.0 .2 – Fred37b