2011-10-24 9 views
0

私はAndroidアプリを開発しています(スクリーンショットを参照)。Androidビュー特定のポイント以下にクリッピングされました

私はグラフィックエディタでうまく見えるレイアウトを持っています。しかし、アプリケーションがエミュレータで実行されているときだけでなく、アンドロイド携帯電話でも画面の下部1/4が切り取られます。アプリにはいくつかのアクティビティがあり、その問題はすべてに広がっているようです。

The view from my eclipse editor The view from my android emulator

ここで私が使用しているレイアウトです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:layout_width="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" android:clipChildren="false" android:clipToPadding="false" android:layout_height="fill_parent"> 
    <ImageView android:layout_height="wrap_content" android:src="@drawable/simpsonstextblack" android:layout_width="fill_parent" android:id="@+id/TitleImage" android:paddingBottom="25dp"></ImageView> 
    <RelativeLayout android:layout_below="@+id/TitleImage" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/RelativeLayout1" android:padding="5dp"> 
     <Button android:text="Take the Simpsons Challenge" android:gravity="center" android:clickable="true" android:id="@+id/ChallengeButton" android:layout_width="fill_parent" android:textSize="20dp" android:background="@drawable/buttonbackgroundblue" android:layout_height="50dp"></Button> 
     <TextView android:layout_width="fill_parent" android:layout_below="@+id/ChallengeButton" android:layout_alignLeft="@+id/ChallengeButton" android:id="@+id/spacer1" android:layout_height="6dp"></TextView> 
     <Button android:layout_width="fill_parent" android:text="Free Play" android:clickable="true" android:id="@+id/FreePlayButton" android:layout_height="50dp" android:textSize="20dp" android:background="@drawable/buttonbackgroundblue" android:layout_below="@+id/spacer1"></Button> 
     <TextView android:layout_width="fill_parent" android:id="@+id/spacer2" android:layout_below="@+id/FreePlayButton" android:layout_alignLeft="@+id/FreePlayButton" android:layout_height="6dp"></TextView> 
     <Button android:layout_height="50dp" android:textSize="20dp" android:id="@+id/HighScoreButton" android:background="@drawable/buttonbackgroundblue" android:layout_width="fill_parent" android:text="High Scores" android:layout_below="@+id/spacer2"></Button> 
     <TextView android:layout_width="fill_parent" android:id="@+id/spacer3" android:layout_below="@+id/HighScoreButton" android:layout_alignLeft="@+id/HighScoreButton" android:layout_height="6dp"></TextView> 
     <Button android:layout_height="50dp" android:textSize="20dp" android:id="@+id/HelpButton" android:background="@drawable/buttonbackgroundblue" android:layout_width="fill_parent" android:text="Help" android:layout_below="@+id/spacer3"></Button> 
    </RelativeLayout> 
    <RelativeLayout android:layout_below="@+id/RelativeLayout1" android:layout_width="fill_parent" android:id="@+id/RelativeLayout2" android:clipChildren="false" android:clipToPadding="false" android:layout_height="fill_parent"> 
     <TextView android:id="@+id/spacer1" android:layout_width="fill_parent" android:layout_height="30dp"></TextView> 
     <TextView android:layout_below="@+id/spacer1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textAppearance="?android:attr/textAppearanceMedium" android:id="@+id/QuoteText" android:text='"A woman is a lot like a refrigerator. Six feet tall, 300 pounds…it makes ice. Heres some extra filler text just to demonstrate to you that if you add enough text it will most likely get clipped at some random point in the screen seemingly for no reason."'></TextView> 
    </RelativeLayout> 
</RelativeLayout> 
+0

私のデバイスでこの問題を再現することはできません。あなたのデバイスで実行すると、エミュレータと同じことが表示されますか? – Craigy

+0

はい、スクリーンショットはエミュレータ自体から取得されます。一番下のテキストビューに2行以上のテキストを追加し、クリップされているかどうかを確認してください。 – Allen

+0

私が言っていたことは、エミュレータでは動作するはずですが、エミュレータではなく、物理デバイス上で正常に動作する可能性があるということです。その可能性を排除しようとしています。画面の下部をスクロールするのに十分なテキスト行を追加しましたが、デバイス上の画面の端にクリップするだけです。 – Craigy

答えて

2

私の推測では、あなたのアプリケーションは互換性モードで動作しています。マニフェストで次の設定を試してみてください。

<supports-screens android:smallScreens="true" 
    android:normalScreens="true" 
    android:largeScreens="true" 
    android:anyDensity="true" /> 

それはあなたがここでそれについての詳細を読むことができる問題である場合:http://developer.android.com/guide/topics/manifest/supports-screens-element.html。 短いAndroidで:largeScreensのデフォルト値はaccrosのバージョンによって異なります:)

1

問題があなたの最後のTextView(@+id/QuoteText)がandroid:visibility="invisible"に設定されていることです。これは、コンテンツが見えないことを意味しますが、引き続きスペースを占有します。代わりにandroid:visibility="gone"を使用します。

私は前に自分の携帯電話で正しく動作しなかったことを謝罪します。テキストはデバイスの画面の最下部に届かなかったので、上部のImageViewにスペースを追加しましたが、テキストを画面から外しているTextViewがプッシュされていました。お役に立てれば!

編集:

これは問題ではありませんでした。私はこの問題は、あなたの一番下RelativeLayoutを底面パネルに固定の高さを与える

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:id="@+id/RelativeLayout1" 
    android:layout_height="200dp"> 

として定義されていることであると信じています。私がandroid:layout_height="200dp"android:layout_height="fill_parent"に変更すると、クリッピングの問題が解消されます。おそらく、他の活動にも同じ問題がありますか?

レイアウトが機能しない理由はわかりませんが、RelativeLayoutsの代わりにLinearLayoutsを使用すると、同じことをより簡単かつ効率的に達成できると思います。そしておそらくそれは途中であなたの問題を解決するでしょう。スペーサービューを使用する代わりに、パディングを使用する方が良いと思います。ここに私の意味は次のとおりです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/TitleImage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="fitStart" 
     android:src="@drawable/simpsonstextblack" > 
    </ImageView> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/TitleImage" 
     android:orientation="vertical" 
     android:padding="5dp" > 

     <Button 
      android:id="@+id/ChallengeButton" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:clickable="true" 
      android:paddingLeft="6dp" 
      android:paddingRight="6dp" 
      android:text="Take the Simpsons Challenge" 
      android:textSize="20dp" > 
     </Button> 

     <Button 
      android:id="@+id/FreePlayButton" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:clickable="true" 
      android:paddingLeft="6dp" 
      android:paddingRight="6dp" 
      android:text="Free Play" 
      android:textSize="20dp" > 
     </Button> 

     <Button 
      android:id="@+id/HighScoreButton" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:paddingLeft="6dp" 
      android:paddingRight="6dp" 
      android:text="High Scores" 
      android:textSize="20dp" > 
     </Button> 

     <Button 
      android:id="@+id/HelpButton" 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:paddingLeft="6dp" 
      android:paddingRight="6dp" 
      android:text="Help" 
      android:textSize="20dp" > 
     </Button> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/QuoteText" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="30dp" 
      android:text="&quot;A woman is a lot like a refrigerator. Six feet tall, 300 pounds…it makes ice. Heres some extra filler text just to demonstrate to you that if you add enough text it will most likely get clipped at some random point in the screen seemingly for no reason. &quot;" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 
    </LinearLayout> 
</LinearLayout> 
+0

私はそのテキストビューが見えないことに気付いています。私はそれを取り除いたはずですが、それは問題ではありません(スクリーンを75%クリップして見積もりテキストを閉じます)。問題はアプリケーション内のすべてのアクティビティに広がっています。問題はおそらく個々のビュー要素ではないでしょう – Allen

+0

あなたは正しいですが、それは問題ではありませんでした。私は自分の答えを編集して助けてくれたかどうかを確認してください – Craigy

+0

効果がないのにまだクリップされていません – Allen

関連する問題