2017-09-08 115 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