Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android按钮默认为黑色_Java_Android_Android Layout_Android Button - Fatal编程技术网

Java Android按钮默认为黑色

Java Android按钮默认为黑色,java,android,android-layout,android-button,Java,Android,Android Layout,Android Button,我通过编程创建的按钮具有非常奇怪的行为。在一个项目中,它们是“正常的灰色”,而在另一个项目中,它们是黑色的。我在两个项目中使用相同的清单 My activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match

我通过编程创建的按钮具有非常奇怪的行为。在一个项目中,它们是“正常的灰色”,而在另一个项目中,它们是黑色的。我在两个项目中使用相同的清单

My activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    tools:context="com.example.maris.caffeappapi.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/buttonlayout"
    android:orientation="vertical">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Call Service"
        android:id="@+id/button1" />

    <TextView
        android:paddingTop="16px"
        android:id="@+id/jsonParsed"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />

    </LinearLayout>
</RelativeLayout>
这是我的第一个项目

这是我在第二个项目中得到的,

你的主题(在styles.xml中)是什么?两个主题中的主题相同(在styles.xml中)是什么?两个主题中的主题相同
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Button myButton = new Button(this.context);
myButton.setText(object.getString("name"));

LinearLayout ll = (LinearLayout)findViewById(R.id.buttonlayout);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

ll.addView(myButton, lp);