Center View in RelativeLayout Android
RelativeLayout like parent, child Srollview is centered horizontal.
Second RelativeLayout in SrollView have gravity center, every child will centered horizontally and vertically.
Second RelativeLayout in SrollView have gravity center, every child will centered horizontally and vertically.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView2" >
<RelativeLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:background="#e6f825"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
396LW NO topic_id
AD
Další témata ....(Topics)
Check if in drawable folder have two picture with same name and delete one.
For example:
Check the module build folder in Android Studio for two files with same names.
For example:
image_1.jpg
image_1.png
Check the module build folder in Android Studio for two files with same names.
C:\Users\myFolder\AndroidStudioProjects\Project\yourModule\build\intermediates\res\merged\debug\drawable\
Cycle for in Java example
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = { "Hello", "people", "hello", "world!" };
for (int i = 0; // start position , first cycle i == 0
i < arrayOfString.length; // if i < 4 (length of array) do loop
i++ // incrementation after cycle
){
System.out.println(arrayOfString[i]);
// i++ incrementation
}
}
}
Environment.getExternalStorageDirectory()+ File.separator
AndroidManifest.xml
Boolean canWrite = Environment.getExternalStorageDirectory().canWrite() ;
if(canWrite){
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "my_image.jpg")
f.createNewFile();
}else{
}
AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Add and shuffle elements in LinkedList or ArrayList Java basic example.
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "End" };
List<String> arrayList = new LinkedList<String>();
for(String s: arrayOfString)
arrayList.add(s);
Collections.shuffle(arrayList);
System.out.println(arrayList);
}
}
/*
[hello, world!, bye-bye, nothing, people, End, Hello]
*/
Incorrect line ending: found carriage return (\r) without corresponding newline (
)
Move mouse cursor on error text and press Ctrl+1
Select Fix line endings and press Enter
See image below:
)
Move mouse cursor on error text and press Ctrl+1
Select Fix line endings and press Enter
See image below:
Editace: 2016-03-14 17:39:25
Počet článků v kategorii: 396
Url:center-view-in-relativelayout-android