VideoView未填充布局

时间:2015-12-29 13:25:04

标签: android android-layout android-videoview

我制作了一个视频视图,屏幕底部还有另一个相对布局。在模拟器中,它显示确定它应该如何,但是当我启动应用程序时它不会。

Image from emulator

现在,当我启动时,它会向我显示这样的布局

Layout when launching app

我在背后的代码中做错了吗?

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

    <VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/buttonsLayout" />

    <RelativeLayout
        android:id="@+id/buttonsLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#404040"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/button_accept_video"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_margin="10dp"
            android:src="@mipmap/accept" />

        <ImageView
            android:id="@+id/button_reject_video"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_margin="10dp"
            android:src="@mipmap/reject" />

    </RelativeLayout>
</RelativeLayout>

2 个答案:

答案 0 :(得分:7)

尝试在import requests,json,time searchTerms = input("input places separated by comma") start_time = time.time() #timer searchTerms = searchTerms.split(',') for i in searchTerms: r1 = requests.get('https://maps.googleapis.com/maps/api/place/textsearch/json?query='+ i +'&key=MY_KEY') a = r1.json() pid = a['results'][0]['place_id'] r2 = requests.get('https://maps.googleapis.com/maps/api/place/details/json?placeid='+pid+'&key=MY_KEY') b = r2.json() phone = b['result']['formatted_phone_number'] name = b['result']['name'] website = b['result']['website'] print(phone+' '+name+' '+website) print("--- %s seconds ---" % (time.time() - start_time)) 中添加以下属性。

VideoView

检查this以供参考。

答案 1 :(得分:1)

试试这个

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

<VideoView android:id="@+id/videoViewRelative"
     android:layout_alignParentTop="true"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
</VideoView>

希望这会对你有所帮助