2017-08-05 19 views
-3

私はAndroid開発が初めてで、ボタンだけでアプリケーションを作成しようとしています。Android - ボタンが表示されない

私はレイアウトを作成するためにIntellij Designツールを使用していますが、すべては問題なく表示されますが、アプリを実行しようとすると画面にボタンが表示されません。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.test.button test.MainActivity" tools:layout_editor_absoluteY="81dp" 
     tools:layout_editor_absoluteX="0dp"> 

    <Button 
      android:text="Hello" 
      android:id="@+id/button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" 
      tools:layout_constraintTop_creator="1" tools:layout_constraintRight_creator="1" 
      tools:layout_constraintBottom_creator="1" tools:layout_constraintLeft_creator="1"/> 
</android.support.constraint.ConstraintLayout> 

編集: 変更アンドロイド:layout_width =アンドロイドに "0dp":layout_width = "wrap_content" 変わらないもの

は、ここに私の活動ファイルです。

+0

アンドロイド:layout_width = "0dp" =>アンドロイド:layout_width = "wrap_content" –

+0

あなたがアンドロイドを持っている:layout_width = "0dp" – Mike

+0

はまだまだ – Itega

答えて

0

ボタンに幅0を指定しました。それはあなたには見えません。 Buttonのコードを以下に示します。

<Button 
     android:id="@+id/join_now" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="15dp" 
     android:text="Join Now"/> 
+0

で作業していない:ツール:layout_editor_absoluteY = "81dp" ツール:layout_editor_absoluteX = "0dp" – Itega

+0

はこの二行削除機能していないlayout_width = "wrap_content" –

+0

ツールが機能しませんでした – Itega

0

あなたは何の制約が与えられていない場合は(0,0)にすべてのボタンをリセットしますConstraintLayoutを、使用しているからです。 RelativeLayoutを使用するか、制約を設定してみてください。

関連する問題