Im using the following code to show the camera view within a layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="vertical"
android:weightSum="2">
<RelativeLayout
android:id="#+id/cam_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary">
</LinearLayout>
<org.opencv.android.JavaCameraView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:id="#+id/AddPersonPreview"
opencv:show_fps="false"
opencv:camera_id="any" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="#color/colorPrimary"
android:layout_weight="0">
</LinearLayout>
</LinearLayout>
Im trying to have the camera view to occupy full width and full height as that of the cam_frame. It occupies the height but the width of the frame is not fully occupied and hence there is a black background alongside the width. How can I be able to sort this out?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/cam_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary">
</LinearLayout>
<org.opencv.android.JavaCameraView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:layout_margin="30dp"
android:id="#+id/AddPersonPreview"
opencv:show_fps="false"
opencv:camera_id="any" />
</RelativeLayout>
</LinearLayout>
Related
Hello guys how can I get a view like this link, it has to be scrollable from vertical and horizontal, I started doing it with recyclerview and it works horizontally but how can I make it to work vertically.
Link of the view to acomplish
https://i.stack.imgur.com/puxEi.png
This is the code for the layouts am using fragments and replacing those on the framelayouts because the test requires me to do so.
--activity main layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#color/colorBlack">
<FrameLayout
android:id="#+id/section1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
<FrameLayout
android:orientation="vertical"
android:id="#+id/section2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
</LinearLayout>
----section1 and section2 code are the same
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="fragments.SectionOne"
android:background="#f2f2f2">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/recyclerView"
android:orientation="horizontal">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
If use scrollview and wrap all this under a single framelayout both sections are overlapping each other
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#color/colorBlack">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/section1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
<FrameLayout
android:orientation="vertical"
android:id="#+id/section2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</FrameLayout>
</FrameLayout>
</ScrollView>
In the code below, the total weight in the parent linear layout is less than the total weight of the its children.So I expect the scroll to work.The first children covers the entire screen.The other child is below the screen, but no scroll.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ActivityHome">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical"
android:weightSum="4">
<!--First children-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="13"
android:orientation="vertical">
</LinearLayout>
<!--Second children-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</ScrollView>
I just have to work with layout_height.How can I do that?
The Problem here is android:weightSum="4" . This is clearly opposite What ScrollView is build for . Remove Weight from layout If View goes out of the screen then it will automatically scroll . Try this for instance :-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ActivityHome">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical"
>
<!--First children-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#android:color/black"
android:orientation="vertical">
</LinearLayout>
<!--Second children-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#android:color/holo_red_light"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</ScrollView>
See This Thread if you want to use android:fillViewport.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width=""
android:layout_height=""/>
<WebView
android:layout_width=""
android:layout_height=""/>
</LinearLayout>
</ScrollView>
This like layout I want to achieve where full screen need to be scrollable
Any one suggest better ideas
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#dedede"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="30dp"
android:text="LinearLayout" />
</LinearLayout>
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</WebView>
</LinearLayout>
</ScrollView>
</LinearLayout>
I am trying to create a black view and placing it on top of another view as can be seen in the image below. So far so good.
But I can't figure out how to place the black view in the bottom of the screen? (still on top of the white pdf background...)
Here is my xml code so far:
<?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"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/background_pdf"
android:layout_below="#+id/background_pdf2"
android:orientation="vertical"
>
<com.radaee.pdf.MLPDFViewer
android:id="#+id/pdf"
android:background="#android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/background_pdf2"
android:orientation="vertical"
android:gravity="bottom"
android:layout_gravity="bottom"
>
<View
android:layout_width="match_parent"
android:layout_height="75px"
android:gravity="bottom"
android:layout_gravity="bottom"
android:background="#android:color/black"
/>
</LinearLayout>
</RelativeLayout>
If I add the following code android:layout_alignParentBottom="true" to android:id="#+id/background_pdf2" my result is the following:
As you can see the black view is placed at the bottom but the main-view (white pdf) dissapears. I don't understand this...
Give android:layout_alignParentBottom="true" to your Linear layout with id background_pdf2, like below
<?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"
android:orientation="vertical">
<LinearLayout
android:id="#+id/background_pdf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.radaee.pdf.MLPDFViewer
android:id="#+id/pdf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:id="#+id/background_pdf2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="75px"
android:layout_gravity="bottom"
android:background="#android:color/black"
android:gravity="bottom"
/>
</LinearLayout>
</RelativeLayout>
I am trying to display high-resolution images inside the expandable list view. Although I was able to display the image but it is not covering the entire screen width. I have tried numerous combination of match_parent and wrap_content, but still doesn't get any success. I am using picasso library to load image from url and display it in expandable list view.
activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="deev.com.company.albumsdetails.MainActivity">
<TabHost
android:id="#+id/tabsForDetailsandAlbums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/albumsTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/metallicSilver"
android:orientation="vertical">
<ExpandableListView
android:id="#+id/albumsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:indicatorLeft="android:attr/expandableListPreferredItemIndicatorLeft"
android:divider="#color/blackBottom"
android:dividerHeight="2dp">
</ExpandableListView>
</LinearLayout>
<LinearLayout
android:id="#+id/postsTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/metallicSilver"
android:orientation="vertical">
<ListView
android:id="#+id/tab2List"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#color/blackBottom"
android:dividerHeight="2px"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
album_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp">
<TextView
android:id="#+id/albumHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20dp"
android:paddingLeft="?android:attr/expandableListPreferredItemIndicatorLeft"
/>
</LinearLayout>
album_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/albumContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"/>
<ImageView
android:id="#+id/albumContent2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
</LinearLayout>