Skip to content

Latest commit

History

History
95 lines (91 loc) · 3.01 KB

File metadata and controls

95 lines (91 loc) · 3.01 KB

I will update this file at when i find new things


for remove title bar

// go to (...)\styles.xml <stylename="AppTheme"parent="@android:style/Theme.NoTitleBar" />
// detail is -> style/Theme.NoTitleBar

customizing objects / drawables

// create xml file to -> (...) res/drawable/
// file name needs to be lower case
// paste this code =
<?xml version="1.0" encoding="UTF-8"?> <shapexmlns:android="http://schemas.android.com/apk/res/android"> <solidandroid:color="#ffffffff"/> </shape>
//usage = android:background="@drawable/ name"
// you can use this pages to learn inner elements =

positioning in relative layout


get battery percent

importandroid.content.Intent;
importandroid.content.IntentFilter;
importandroid.os.BatteryManager;
IntentFilterifilter = newIntentFilter(Intent.ACTION_BATTERY_CHANGED);
IntentbatteryStatus = getApplicationContext().registerReceiver(null, ifilter);
intlevel = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
intscale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
floatbatteryPct = level / (float)scale;
floatp =(batteryPct * 100);

object get width - height

importandroid.widget.*;
importandroid.widget.TextView;
importandroid.view.View;
importandroid.view.ViewGroup.LayoutParams;
importandroid.view.ViewGroup;
finalViewview1=(View) findViewById(R.id.viewId);
// in this solution, view1 is a guide for view2view1.post(newRunnable(){
@Overridepublicvoidrun()
{
view1.getWidth();
view1.getHeight();
// using sizesViewview2=(View) findViewById(R.id.view2);
ViewGroup.LayoutParamsviewG1=view1.getLayoutParams();
viewG1.width=view1.getWidth()-50;
view2.setLayoutParams(viewG1);
}
});
links

Android Studio - Adb / Virtual device connection

go to this folder (default) ->%localappdata% / android / sdk / platform-tools /
and copypath (for example)-> C:\Users\UserName\AppData\Local\Android\Sdk\platform-tools
open cmd and change directory to that path ->cd"C:\Users\UserName\AppData\Local\Android\Sdk\platform-tools"
and use adb commands , example -> adb connect 127.0.0.1:5555(this is the virtual device's address)

Android Studio - Licence fix

go to settings / android sdk
change tab SDK Platforms -> SDK Tools
download Google Play Licensing Library you can also download Android SDK build Tools

if you cant get string for condition use .equals

Stringx="Hello World!";
if(x.replace(" ","").equals("HelloWorld!")==true)
{
System.out.println(" HELLO ");
}

Fit UI for all devices

use Relative Layout Instead Other Layouts