Hi dear developers,
I spend much time with this issue.
When I create LinearLayout with four ToggleButtons with self images, button image will not keep aspect ratio, images will be deformed.
Button images pressed in vertical, not in horizontal.
This is layout code with deformed images:
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0px"
androidrientation="horizontal">
<ToggleButton
android:id="@+id/bt1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/led"
android:text="Led"
android:textOff="BT1"
android:textOn="BT1" />
<ToggleButton
android:id="@+id/bt2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/led"
android:text="Led"
android:textOff="BT2"
android:textOn="BT2" />
<ToggleButton
android:id="@+id/bt3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/led"
android:text="Led"
android:textOff="BT3"
android:textOn="BT3" />
<ToggleButton
android:id="@+id/bt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/led"
android:text="Led"
android:textOff="BT4"
android:textOn="BT4" />
</LinearLayout>
When I create similar LinearLayout with four ImageViews instead of ToggleButtons with same images, images not will be deformed. Same images keep aspect ratio. Button images pressed in vertical and horizontal with same ratio.
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0px"
androidrientation="horizontal">
<ImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/led" />
<ImageView
android:id="@+id/img2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/led" />
<ImageView
android:id="@+id/img3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/led" />
<ImageView
android:id="@+id/img4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/led" />
</LinearLayout>
I don't know, why it's behavior different. Size of image is 128 x 128 pixels in png file.
How I can reach that ToggleButton's image will keep aspect ratio for all relative sizes?
Application is compiled in Android Studio 3.6.1 with build gradle:
...
android {
compileSdkVersion 25
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.nabto.androidaudiodemo"
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
Thank you for your help
Srapur
Related
Hi developers,
I have a special problem and didn't find a solution for it yet. So I hope that anybody here had a similar issue and can point me to a solution.
The problem:
Basically I use an ImageView inside my widgets. When the image is smaller than the ImageViews space then there is no problem.
The problem raises when the image gets bigger than the ImageView.
In some cases I want that the image doesn't get scaled but cropped and then aligned due to the users option.
What I want to achive is that the ImageView gets as big as the image and then is aligned (top, right, bottom, left). The rest of the image should get clipped by the container.
All I could achive until now is that the image gets cropped and centerd (all done by the ImageView).
Here is the xml I use for the widgets:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/widgetbackground"
android:focusable="true" >
<!-- [...] -->
<LinearLayout
android:id="@+id/llTextBlock"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/llText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/llContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<!-- [...] -->
<ImageView
android:id="@+id/imgContentDontScale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/widgetbackground"
android:focusable="true"
android:scaleType="center"
android:visibility="gone" >
</ImageView>
</LinearLayout>
<!-- [...] -->
</LinearLayout>
</LinearLayout>
<!-- [...] -->
</RelativeLayout>
The ImageView in question is the "imgContentDontScale" one.
The solution has to work on widgets (so almost only xml defined excluding the "RemotableViewMethod" marked methods) and ist has to be Froyo compatible.
Thanks
Michael
I have created a new xml file in the res>layout forlder called tabs.xml. It has the following code:
<?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"
androidrientation="vertical" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
androidrientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/Network"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Channel Type:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioButton
android:id="@+id/urbanButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:text="Urban" />
<RadioButton
android:id="@+id/suburbanButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/urbanButton1"
android:layout_alignBottom="@+id/urbanButton1"
android:layout_centerHorizontal="true"
android:text="SubUrban" />
<RadioButton
android:id="@+id/ruralButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/suburbanButton2"
android:layout_alignBottom="@+id/suburbanButton2"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:text="Rural" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/urbanButton1"
android:text="Characteristics of Channel:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/suburbanButton2"
android:layout_below="@+id/textView2"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView3"
android:layout_toLeftOf="@+id/ruralButton3"
android:text="Manual Override" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/power"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/Connectivity"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/Offline"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</FrameLayout>
</LinearLayout>`enter code here`
</TabHost>
</LinearLayout>
Now i also have a andoid activity_main.xml in the same folder which i added nothing to it. i also created a java file called Tabs.Java and put it in the src folder under src>com.example.qosmetre>Tabs.Java with the following code
package com.example.qosmetre;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Tabs extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
}
}
Now my question is, when i run my app on the terminal or in debugging mode, how come nothing is showing up but a blank screen? Like i want the tabs to show up first thing with all the stuff underneath them as shown in the code above. Also how would i import a library for scatter plotting data that would be in my app?
I need to know where and what files to put what code in because im just a beginner and i dont know too much so ill need big guidence.
Thanks again in advance.
Hi All!!
I'm going crazy to edit my mms.apk!
I want to change the size of EditText without assign static value of height, but how can I do this??
Graphically, this is what I want: (see attachment; note: the red area is as it is now my mms.apk; the green area is the results of what I want)
Part of the code to be changed I think that's (compose_message_activity.xml in res / layout):
Code:
<RelativeLayout android:layout_gravity="bottom" android:id="@id/bottom_panel" android:background="#ff737b82" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="right" android:orientation="vertical" android:id="@id/sendbuttons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="6.299988dip" android:layout_alignParentRight="true" android:layout_alignParentBottom="true">
<TextView android:textSize="15.0sp" android:textColor="#ffc7c7c7" android:gravity="right" android:id="@id/message_size" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="2.0dip" />
<Button android:textSize="15.0sp" android:textColor="@drawable/selector_send_btn_text_color" android:id="@id/send_button" android:background="@drawable/selector_send_button" android:nextFocusLeft="@id/embedded_text_editor" android:layout_width="55.0dip" android:layout_height="48.0dip" android:layout_marginBottom="3.0dip" android:text="@string/send" />
<ImageButton android:layout_gravity="center_vertical" android:id="@id/attach_button" android:background="@drawable/selector_attachment_button" android:visibility="gone" android:layout_width="1.0dip" android:layout_height="1.0dip" android:layout_marginBottom="1.2999878dip" />
</LinearLayout>
<EditText android:layout_marginBottom="3.0dip" android:textSize="17.0sp" android:textColor="#ffffffff" android:textColorHint="#ff898989" android:gravity="top" android:id="@id/embedded_text_editor" android:background="@drawable/textfield_msg" android:nextFocusRight="@id/send_button" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginLeft="3.0dip" android:layout_marginTop="5.0dip" android:hint="@string/type_to_compose_text_enter_to_send" android:capitalize="sentences" android:autoText="true" android:layout_toLeftOf="@id/sendbuttons" android:layout_alignParentLeft="true" android:inputType="textCapSentences|textAutoCorrect|textMultiLine" android:imeOptions="actionSend|flagNoEnterAction" />
</RelativeLayout>
Help please
(I'm on Android 2.3.6 Gingerbread)
IM PORT GAMMA FEATURES
THIS IS XML IN LAYOUT FOLDER FROM CM11
PLEASE HELP ME TO PORT THIS TO CM9 XML
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:paddingStart="20dip"
android:paddingEnd="20dip"
android:paddingBottom="20dip">
<TextView android:id="@+id/color_red_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/color_red_title"
android:paddingTop="10dip" />
<TextView android:id="@+id/color_red_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingTop="10dip" />
<SeekBar android:id="@+id/color_red_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_red_text"
android:paddingTop="2dip" />
<TextView android:id="@+id/color_green_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/color_red_seekbar"
android:text="@string/color_green_title"
android:paddingTop="10dip" />
<TextView android:id="@+id/color_green_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/color_red_seekbar"
android:layout_alignParentRight="true"
android:paddingTop="10dip" />
<SeekBar android:id="@+id/color_green_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_green_text"
android:paddingTop="2dip" />
<TextView android:id="@+id/color_blue_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_green_seekbar"
android:text="@string/color_blue_title"
android:paddingTop="10dip" />
<TextView android:id="@+id/color_blue_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/color_green_seekbar"
android:layout_alignParentRight="true"
android:paddingTop="10dip" />
<SeekBar android:id="@+id/color_blue_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_blue_text"
android:paddingTop="2dip" />
<ImageView android:id="@+id/black_scale_picture_color"
android:src="@drawable/color_tuning_preview"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_below="@id/color_blue_seekbar"
android:paddingTop="20dip" />
</RelativeLayout>
</ScrollView>
BUT I HAVE THIS ERROR
packages/apps/Settings/res/layout/display_color_calibration.xml:58: error: Error parsing XML: mismatched tag
How can I use my gesture overlay view with navigation drawer? I'm adding the navigation drawer to the app with gesture overlay already working. I want to just add the swipe menu and if i have to give up the swipe gesture for the just have the action bar push button is fine. I just can't figure how to combine? I get an error before the app can start saying the it can't inflate class Drawer layout. See my XML code under.
Code:
<android.gesture.GestureOverlayView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gestureOverlayView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#666"
android:dividerHeight="1dp"
android:background="#333"
android:paddingLeft="15sp"
android:paddingRight="15sp"
/>
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/timerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5sp"
android:text="@string/startTime"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="30sp" />
<TextView
android:id="@+id/instructionTextView"
android:layout_width="574dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:textSize="40sp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</android.gesture.GestureOverlayView>