2016-12-20 12 views
1

Current Playbar 私は、使用しているプレイバーを含むFrameLayoutを持っています。これは、トグルと一緒に演奏する音楽に関する情報を表示します。何らかの理由で、フレームレイアウトの上部にあるパディングを消すことができません。私はすべての要素の0dpとレイアウト全体をプログラム的にXMLで作成しようとしましたが、何も動いていません。私はそれがFrameLayoutに組み込まれた自然な振る舞いであると仮定しています。 FrameLayoutを同じ目標高さ(56dp/dimen/playbar_size)に設定しようとしましたが、パディングはまだあります。 FrameLayoutの余白/詰め込みがなくならない

<SeekBar 
    style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/progress" 
    android:layout_marginLeft="@dimen/playbar_size" 
    android:layout_marginTop="-8dp" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="45dp" 
    android:layout_marginLeft="64dp" 
    android:orientation="horizontal" 
    android:layout_gravity="right|bottom"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_weight="1" 
     android:gravity="center_vertical" 
     android:orientation="vertical" 
     android:paddingTop="5dp"> 

     <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#fff" 
      android:textSize="14dp" 
      android:singleLine="true" 
      android:lines="1" 
      android:maxLines="1" 
      android:ellipsize="end" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/subtitle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#fff" 
      android:textSize="12dp" 
      android:singleLine="true" 
      android:lines="1" 
      android:maxLines="1" 
      android:ellipsize="end" 
      android:layout_marginLeft="8dp" /> 
    </LinearLayout> 

    <ImageButton 
     android:id="@+id/toggle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:soundEffectsEnabled="false" 
     android:padding="12dp" 
     app:srcCompat="@drawable/ic_pause_dark" 
     android:layout_gravity="bottom" 
     android:background="@android:color/transparent" /> 

    <ImageButton 
     android:id="@+id/next" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:soundEffectsEnabled="false" 
     android:padding="12dp" 
     app:srcCompat="@drawable/quantum_ic_skip_next_white_24" 
     android:layout_gravity="bottom" /> 
</LinearLayout> 

<ImageView 
    android:id="@+id/art" 
    android:layout_width="@dimen/playbar_size" 
    android:layout_height="@dimen/playbar_size" 
    android:layout_gravity="left|top" 
    android:layout_marginTop="0dp" /> 

</FrameLayout> 

なしパディングと、ビュー理想とずっとトップをシークバー - これはそれをすることになっている実際の高さです。

<ImageView 
android:id="@+id/art" 
android:layout_width="@dimen/playbar_size" 
android:layout_height="@dimen/playbar_size" 
android:layout_gravity="left|top" 
android:layout_marginTop="0dp" /> 

あなたは

android:layout_gravity="left|top" 

可能性があるので、重力を入れているので、この画像表示はフレームレイアウトの上部を覆っている:私は、パディングは、このためであると考えてい

Desired view, with no padding and seekbar all the way the top – this is actual height it is supposed to be

答えて

0

私は2つのことを行うことでそれを理解しました。 背景をXMLの色に設定するのではなく、0のパディングがあり、私が望む色を持つ新しいシェイプオブジェクトを作成しました。

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="@color/colorAccentBrightOpaque"/> 
<padding 
    android:bottom="0dip" 
    android:left="0dip" 
    android:right="0dip" 
    android:top="0dip"/> 
</shape> 

次に、プログラムで、バックグラウンドをJavaコードでシェイプリソースに設定し、プログラムで埋め込みを0に設定しました。

playbar.setBackgroundResource(R.drawable.playbar_background); 
playbar.setPadding(0,0,0,0); 
0

あなたはそれを削除してチェックしてみてください?

+0

私はこれを試していて、それも修正していません。私はもう一度やり直してみましたが、まだ動作しません:/ – osharifali

関連する問題