それは、これはかなり多くのバグであることは注目に値しますapi-22サポートライブラリは、すべてのボタンを1つの行に配置しようとしているためです。 api-23サポートライブラリでは、各ボタンがそれ自身の行にある新しいレイアウトに切り替えることで修正されています。
私は、サポートライブラリAlertDialogとKitKat 4.4.4を搭載したデバイスで、2つの異なるプロジェクトでコードをテストしました。
両方の試験について同じコード:
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("If you like this app, please rate it on the Google Play Store!")
.setPositiveButton("Rate me!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton("No thanks and do not ask me again", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNeutralButton("Remind me later", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
}
}
まず、プロジェクトにこのGradleの構成を有する(すべてのAPI-22の設定は):
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
これは結果であります
次に、このコンフィグレーションを持つ別のプロジェクトイオン(すべてのAPI-23の設定):
ので、これのための1つの修正プログラムは、API-23のサポートライブラリを使用するために、次のようになります。これは、同じコードの結果です
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.testprojecttwo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
。
エミュレータでAPI 22、つまり5.1.1でテストしましたか? –
'android.app.AlertDialog'または' android.support.v7.app.AlertDialog'を使用していますか? –
スタイルを設定しないと、デバイステーマを設定してもデバイスが独自のデフォルトスタイルを使用することがあります。あなたがスタイルを設定していない場合は、そのようなものです。 –