2016-06-28 40 views
0

全画面表示にボタンを表示しようとしています。 I tried to use RelativeLayoutこの質問に示されているように私はボタンが表示されません。全画面表示でボタンが見えない画像表示

このコードが機能しない理由を教えてもらえますか?

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/pitchImageView" 
     android:src="@drawable/gaa_pitch" 
     android:scaleType="centerCrop"/> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/start" 
     android:id="@+id/stopwatchButton" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true"/> 
</RelativeLayout> 

重複した質問に該当する場合は、お詫び申し上げます。

EDIT: アクティビティのスクリーンショット。

Android design tab

Emulator at runtime

+1

であるあなたはそれのスクリーンショットを投稿することができますか? –

答えて

0
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/pitchImageView" 
     android:src="@drawable/gaa_pitch" 
     android:scaleType="centerCrop"/> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/start" 
     android:id="@+id/stopwatchButton" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true"/> 

</RelativeLayout> 
0
あなたは、代わり FrameLayoutを使用し、そしてこのサイトチェックアウトすることができ

私の友人:Android Frame Layout

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/pitchImageView" 
    android:src="@drawable/desert_road" 
    android:scaleType="centerCrop"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Start" 
    android:src="@drawable/ic_clear_white_24dp" 
    android:id="@+id/stopwatchButton" 
    android:layout_gravity="center" /> 
</FrameLayout> 

結果:

0

これは一般的な「問題」です。あなたは物事のカップルを試すことができます :

  1. を無効にすることなく、キャッシュを無効にし、Androidのメーカーを再起動するか、単に再起動Run -> Clean and rerunオプション

  2. それともBuild -> Clean projectまたはBuild -> Rebuild Projectオプション
をお試しください

完了したら、プロジェクトをもう一度実行します。

0

まあ、私はそれが働いてしまった、私はまさにそれを修正かを説明することはできませんが、これらは私が撮った手順は次のとおりです。内容や活動の分割を活用

  1. を。 (これの例を得るためにアンドロイドスタジオで基本的な活動を作成する)。
  2. バージョン対応のフォルダ内の他のバージョンのレイアウトファイル(「layout-v24」など)を削除しました。
  3. 私は自分のコードを変更したときはいつでも、 "クリーン"と "再ビルド"プロジェクトオプションを使用しました。

活動xmlファイル:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fitsSystemWindows="true"> 

    <include layout="@layout/content_record_game"/> 
</android.support.design.widget.CoordinatorLayout> 

これは私のcontent.xmlファイル

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

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/pitchImageView" 
    android:contentDescription="@string/image_of_a_gaa_pitch" 
    android:src="@drawable/gaa_pitch" 
    android:scaleType="centerCrop" 
    android:cropToPadding="false" 
    /> 
<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/start" 
    android:id="@+id/stopwatchButton" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" /> 
</RelativeLayout> 
関連する問題