Align kids layouts

Asked

Viewed 51 times

0

I own an android project that is basically an app to download and watch videos online, I was using a custom code from a video controller to the player I picked up on the internet, however I decided to create my own to be able to better customize and because I intend to implement the screen cast in the player, at first it works well, but I can not organize the layout of the controller correctly, I’m trying to create something similar to the Netflix player (example image below) where pause buttons and fast forward and rewind fiction in the middle of the screen while controllers at the base of the screen:

Netflix player

My xml:

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


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center">

        <ImageButton
            android:id="@+id/vp_fast_rewind"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.8"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_rw_10" />

        <ImageButton
            android:id="@+id/vp_btn_PlayPause"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_pause_circle_outline" />

        <ImageButton
            android:id="@+id/vp_fast_forward"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.8"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/ic_ffw_10" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="bottom">

        <TextView
            android:id="@+id/vp_initialTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <SeekBar
            android:id="@+id/vp_timeline"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/vp_finalTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>

But all child layouts elements are getting on top:

inserir a descrição da imagem aqui

  • Because you don’t try to do with ConstraintLayout ? is much simpler to make complex views like yours, as well as responsive. https://developer.android.com/training/constraint-layout/

  • I’ve thought about using Constraintlayout for the player, I actually already use in my application, but structurally the player would be something more linear.

1 answer

0

When inserting new elements they always enter at the top on the left. Use the property android:layout_marginTop and android:layout_marginLeft to store your items

  • Is there any way to insert the margin so that it automatically calculates the height to always keep in the center?

  • I don’t think so, but I’ve never tried it before.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.