2017-01-30 6 views
-1

私はJavaとXMLプログラミングの新機能です。断片化されたアクティビティを作成しています。コードの実行やデバッグ時にエラーはありませんが、VideoViewは表示されません。 、 アイデアは、私は、スクロール可能なコンテンツ(可能性があります)として、テキストビューとビデオビューでタブ付きの活動をしたいですか?もう1つはAPIのレベルは何とか影響力がありますか?ラップに応じて/ビデオビューがデバイスやXMLデザインに表示されない

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/mencucitangan_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.panduanberwudhu.MencuciTangan"> 

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/app_name" 
      /> 

     <VideoView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/videoplayer" 
      android:layout_gravity="bottom" 
      /> 

    </LinearLayout> 
</ScrollView> 
+1

をあなたの 'TextView'が原因match_parent'属性'にレイアウト全体を覆っています。 –

+0

android:layout_width = "wrap_content" アンドロイド:layout_height = "wrap_content"をチェックしてみてください –

+0

これを試してみましたが、テキストビューの幅と高さをまだ編集していないので、どうもありがとうございます –

答えて

1

使用このレイアウト、高さRelativelayoutが増加しますwrap_content次のとおりです。

package com.panduanberwudhu; 

import android.net.Uri; 
import android.support.annotation.Nullable; 
import android.support.v4.app.Fragment; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.MediaController; 
import android.widget.VideoView; 

public class MencuciTangan extends Fragment { 

private VideoView player; 
private String videopath; 
private MediaController mediacon; 
public View rootView; 

//@Nullable 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { 

    rootView = inflater.inflate(R.layout.mencucitangan_layout, container, false); 
    mediacon = new MediaController(getActivity()); 

    player = (VideoView) rootView.findViewById(R.id.videoplayer); 
    videopath = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.washhand; 
    player.setVideoURI(Uri.parse(videopath)); 
    player.setMediaController(mediacon); 
    mediacon.setAnchorView(player); 
    player.start(); 

    return rootView; 
    //return inflater.inflate(R.layout.mencucitangan_layout,container,false); 
    } 
} 

とレイアウトコード:まだキットカット に自分の携帯電話は、ここ(フラグメント)のコードです内容はScrollViewの中にあるため

私はLinearlayoutとして、ハードコーディングされたいくつかの値が削除さ:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/mencucitangan_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/app_name" 
     android:id="@+id/ap" 
     android:textSize="20sp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" /> 

    <VideoView 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:layout_marginTop="50dp" 
     android:foregroundGravity="center" 
     android:id="@+id/videoplayer" /> 

</RelativeLayout> 
</ScrollView> 

が出力:

enter image description here

+0

- ありがとうございます –

+0

クール、回答者を受け入れることを検討 – W4R10CK

関連する問題