2012-03-08 13 views
1

私はプレイリストの画面上のほぼすべての領域を使用する音楽プレーヤーを作ろうとしています。 scrrenの下部に、再生/一時停止ボタン、シークバー、停止ボタンがある小さな「プレーヤー」が表示されます。 「プレーヤー」を上にドラッグすると、アルバムカバーとその他の情報が表示されます。SlidingDrawerのハンドルのSeekbar

だから、私はレイアウトを完了しましたが、私はシークバーの親指を動かすことができません。 私はこれがスライディングドローラーのハンドルの一部だからだと思っています。 もし私が正しければ、これを行う他の方法はありますか?

はここ

<SlidingDrawer 
       android:id="@+id/slidingDrawer1" 
       android:layout_width="match_parent" 
       android:layout_height="450dp" 
       android:layout_gravity="bottom" 
       android:content="@+id/content" 
       android:handle="@+id/handle" > 

       <TableRow 
       android:id="@+id/handle" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/hz_background_gradient" 
       android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/linearLayout5" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 


    <ImageView 
     android:id="@+id/imageButton1" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:src="@drawable/playback_play" 
     android:layout_marginLeft="6dp" 
     android:layout_marginTop="4dp" /> 

     <SeekBar android:id="@+id/editText1" 
     android:layout_width="203dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_weight="0.45" 
     android:layout_marginTop="8dp" 
     android:max="100" /> 
    <ImageView 
     android:id="@+id/imageButton1" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:src="@drawable/playback_stop" 
     android:layout_marginLeft="6dp" 
     android:layout_marginTop="4dp" 
     android:layout_marginRight="5dp" /> 
</LinearLayout> 

      </TableRow> 


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

        <ImageView 
         android:id="@+id/imageView1" 
         android:layout_width="wrap_content" 
         android:layout_height="272dp" 
         android:layout_weight="0.83" 
         android:src="@drawable/ic_launcher" 
         android:layout_marginLeft="25dp" 
         android:layout_marginRight="25dp" 
         android:layout_marginTop="25dp" /> 



        <TableRow 
         android:id="@+id/tbR1" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_weight="0.98" 
         android:background="@drawable/hz_background_gradient" 
         android:orientation="vertical" > 

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

          <TextView 
           android:id="@+id/textView1" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Titel: " 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 


          <TextView 
           android:id="@+id/tvTitel" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:text="Put a spell on you" 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 

         </LinearLayout> 
                <LinearLayout 
          android:id="@+id/linearLayout5" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:orientation="horizontal" > 

          <TextView 
           android:id="@+id/textView1" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Artist: " 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 
                  <TextView 
           android:id="@+id/tvArtist" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:text="Credence Clearwater Revival" 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 

         </LinearLayout> 
         </LinearLayout> 
        </TableRow> 
       </LinearLayout> 
      </SlidingDrawer> 

事前に感謝slidingdrawerのレイアウト:)

答えて

2

オーケーための私のコードです。だから、私はそれを修正した!私がそれを動かすことができなかった理由は、ハンドルを動かしていたので、 でした。だから、もし私が(可能な)シークバーが親指を動かしたいと思ったら、ロックする必要があった。 これは私の解決策です:

ハンドルの左上に「タブ」を追加しました。

これは今

 <SlidingDrawer 
       android:id="@+id/slidingDrawer1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_gravity="bottom" 
       android:allowSingleTap="false" 
       android:content="@+id/content" 
       android:handle="@+id/handle" > 

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


       <TableRow 
         android:layout_width="101px" 
         android:layout_height="wrap_content" 
         android:background="@drawable/test" 
         android:orientation="vertical" > 
                    <TextView 
           android:id="@+id/tvToggleSD" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:text="Visa" 
           android:layout_marginLeft="12dp" 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 

           </TableRow> 
             <TableRow 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:background="@drawable/hz_background_gradient" 
         android:orientation="vertical" > 



    <ImageView 
     android:id="@+id/buttonPlay" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:src="@drawable/playback_play" 
     android:layout_marginLeft="6dp" 
     android:layout_marginTop="4dp" /> 

     <SeekBar android:id="@+id/seekbar1" 
     android:layout_width="203dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_weight="0.45" 
     android:layout_marginTop="8dp" 
     android:max="100" /> 
    <ImageView 
     android:id="@+id/buttonstop" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:src="@drawable/playback_stop" 
     android:layout_marginLeft="6dp" 
     android:layout_marginTop="4dp" 
     android:layout_marginRight="5dp" /> 
    </TableRow> 
</LinearLayout> 


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

        <ImageView 
         android:id="@+id/imgCover" 
         android:layout_width="fill_parent" 
         android:layout_height="272dp" 
         android:layout_weight="0.83" 
         android:src="@drawable/test_cover" 
         android:layout_marginLeft="25dp" 
         android:layout_marginRight="25dp" 
         android:layout_marginTop="25dp" /> 



        <TableRow 
         android:layout_width="fill_parent" 
         android:layout_height="55dp" 
         android:background="@drawable/hz_background_gradient" 
         android:orientation="vertical" > 

         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:orientation="vertical" > 
         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="30dp" 
          android:orientation="horizontal" > 

          <TextView 
           android:id="@+id/textView1" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Titel: " 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 


          <TextView 
           android:id="@+id/tvTitel" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:text="Put a spell on you" 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 

         </LinearLayout> 
                <LinearLayout 
          android:id="@+id/linearLayout5" 
          android:layout_width="match_parent" 
          android:layout_height="30dp" 
          android:orientation="horizontal" > 

          <TextView 
           android:id="@+id/textView1" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Artist: " 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 
                  <TextView 
           android:id="@+id/tvArtist" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:text="Credence Clearwater Revival" 
           android:textAppearance="?android:attr/textAppearanceMedium" /> 

         </LinearLayout> 
         </LinearLayout> 

        </TableRow> 

       </LinearLayout> 

      </SlidingDrawer> 

そしてSlidingDrawerのための私のXMLコードで、私はいくつかの本当に簡単なJavaコードをしました。 この考え方では、sliderDrawerを開いたり閉じたりするには、タブをクリックする必要があります。ここ は、関連するJavaコードです:

sd = (SlidingDrawer) findViewById(R.id.slidingDrawer1); 
    tvToggleSD = (TextView) findViewById(R.id.tvToggleSD); 
    sd.lock(); 
    tvToggleSD.setonclickListener(new onclickListener() { 
    public void onclick(View v) { 
     sd.unlock(); 
     if (sd.isOpened()) { 
      sd.animateClose(); 
      tvToggleSD.setText("Visa"); 
     } else { 
      sd.animateOpen(); 
      tvToggleSD.setText("Dölj"); 
     } 
     sd.lock(); 
    } 
    }); 

希望、これは他の誰か:)

+0

はそんなにあなたに感謝役立ちます –