My user interface looks like that in landscape mode:
But I want to have them in parallel. so the should have width / 2 instead of height/ 2. So how can I change that?
My code looks like that:
<FrameLayout 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:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/photo"
android:layout_weight="0.5"
android:id="#+id/btnTakePhoto" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/video"
android:layout_weight="0.5"
android:id="#+id/btnRecordVideo"
/>
</LinearLayout>
</FrameLayout>
Thanks in advance for your help!
Add layout-land folder in your res folder in app directory and design xml's with same name in this folder . Android frameworks will detects the mode and will select the layout file defined within layout-land folder .
*remember xml file name in layout and layout-land folder should be same .
Related
I'm trying to make a splash screen, I'm doing that with react native, but I'm using android studio to create the style.
First of all, I'm following this video that uses this library.
I have the following code of my splash screen:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="#color/primary"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/launch_screen"
android:scaleType="centerCrop" />
</LinearLayout>
</RelativeLayout>
It looks like this:
As you can see, the quality of the logo is low, and I would like to make it better.
My drawable folder is the following:
Thanks!
It seems that your launch_screen.png file has a small resolution.
Change that file with bigger resolution with better quality.
So a noob question: I started a project with a navigation bar in Xamarin and I just want to change the default icons and change names under them in accordance with my app. Can I do that in the constructor view? The buttons themselves already do what I want them to do but I just want to change their appearance. pic activity_main.xml just in case:
<RelativeLayout 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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/containerTwo"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/navigation" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
android:layout_alignParentBottom="true"
app:menu="#menu/navigation"
android:accessibilityHeading="true"
/>
</RelativeLayout>
</RelativeLayout>
Okay, I got it. What I managed to do:
Used this article
Installed Xamarin.Android.Support.Design
Downloaded desired icons from Asset Studio
Unpacked zip file with icons and placed all of the "drawable" folders in Resources\drawable
changed android:icon parameter in navigaton.xml to one of the downloaded icon names
NOTE: sometimes preview gets messed up, for example it might size icons in different scales but when you emulate the build or execute it on a real phone everything looks fine.
I have a simple activity running my OpenCV application. The app should detect objects from camera and visualize them on a custom SurfaceView. I want to lock the device orientation in portrait mode and rotate my widgets programmatically as the standard camera app does.
Here is the activity layout. It includes OpenCV CameraView and a fragment widget shown above it.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.chessking.android.vision.ui.widget.ExtendedCameraView
android:id="#+id/track_camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
opencv:camera_id="any"
opencv:show_fps="true"/>
<FrameLayout
android:id="#+id/track_fragment_container"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<fragment
android:id="#+id/track_board_preview"
class="com.chessking.android.vision.ui.BoardWidgetFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<Button
android:id="#+id/track_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="16dp"
android:text="#string/scan_action"/>
</RelativeLayout>
Custom SurfaceView is presented in the fragment layout. It is com.convekta.android.chessboard.ChessPanel
<?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:id="#+id/board_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/boardBackground"
android:orientation="vertical">
<include layout="#layout/widget_board_clock_both" />
<com.convekta.android.chessboard.ChessPanel
android:id="#+id/board_panel"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/board_background_transparent"
app:chessPanelBackground="#color/board_background_transparent"
app:chessPanelBorderColor="#color/board_border"
app:chessPanelBorderWidth="1dp"/>
<com.convekta.android.chessboard.NotationView
android:id="#+id/nota"
android:layout_width="match_parent"
android:layout_height="20dp"
android:clipChildren="false"
android:fadeScrollbars="false" />
</LinearLayout>
When I need to rotate the widget layour, I change rotation property of the board_layout.
boardLayout.rotation = degrees.toFloat()
The problem is the rotation works on Android 9, but the canvas is misplaced on Android. Here are screenshots from Android 6 emulator, in portrait mode the app looks normal, in landscape SurfaceView jumps out of its layout.
In the <activity> tag of AndroidManifest.xml, add the line android:screenOrientation="portrait"
eclipse can not recognise my layout folder, my layouts could not be referenced by
R.layout.activity_qr01
and the error says:my layout can not be resolved or is not a field
the code of activity_qr01 is:
<RelativeLayout 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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world"
tools:context=".QR01" />
</RelativeLayout>
Your XML file is in the res/menu folder, it should be in the res/layout folder.
You are missing a </RelativeLayout> at the end.
Also, your file is called activity_qr01.xml, so you must reference it as R.layout.activity_qr01
I am new to Android and trying to learn how to use the multiple layout folders to specify different layouts for different sized devices.
I have tried a few different things, but nothing seems to work to get my emulated tablet to use the larger layout.
My layout directory structure is:
layout
layout-large
layout-sw600dp
layout-xlarge
The main.xml in "layout" is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<SearchView android:id="#+id/searchView"
android:iconifiedByDefault="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="#+id/EarthquakeFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
The main.xml in the other three folders is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<SearchView android:id="#+id/searchView"
android:iconifiedByDefault="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFF"/>
<fragment android:name="com.paad.earthquake.EarthquakeListFragment"
android:id="#+id/EarthquakeListFragment"
android:layout_width="360dp"
android:layout_height="fill_parent"
/>
<fragment android:name="com.paad.earthquake.EarthquakeMapFragment"
android:id="#+id/EarthquakeMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
The emulator setup is trying to emulate the Google Nexus 7:
Target: Google APIs (API level 16)
Skin: WXGA800-7in
SD Card: 16M
I'm using all of the other options that come with the skin, plus hw.keyboard=yes and hw.ramSize=512
Does anyone have any idea why this isn't working?
Thank you for your help!
if you are using a 10" tablet and android 3.2 or above, you should have layout-sw720dp folder to have your layout file