@Override
public void onBackPressed() {
int count = getFragmentManager().getBackStackEntryCount();
if (count == 0) {
super.onBackPressed();
}
else {
getFragmentManager().popBackStack();
}
}
toolbar.setTitleTextColor(0xFFFFFFFF);
toolbar.setTitleTextColor(android.graphics.Color.WHITE);
<item name="android:textColorPrimary">TITLE_COLOR_GOES_HERE</item>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/oolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/primary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/primaryDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
</style>
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<color name="primary">#607D8B</color>
<color name="primaryDark">#455A64</color>
<color name="accent">#FE4564</color>
</resources>
public class MainActivity extends AppCompatActivity {
// ...
}
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:theme="@style/MyTheme"></application>
startActivity(intent);
finish();
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
NavigationView navigationView:
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
View header = navigationView.GetHeaderView(0);
TextView navheader_text = header.FindViewById<TextView>(Resource.Id.navheader_text);
navheader_text.Text = "New text";
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccccc"
android:id="@+id/rel_layout">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:scaleType="centerCrop"
android:id="@+id/tv_movie_item_img360"
android:transitionName="selectedMovie"/>
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#000000"
android:alpha="0.3" />
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="100dp"
android:layout_height="130dp"
android:scaleType="centerCrop"
app:riv_border_width="2dip"
app:riv_border_color="#ffffff"
android:layout_marginStart="14dp"
android:id="@+id/tv_movie_item_img"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="240dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="The Revenant"
android:id="@+id/tv_movie_item_nameRU"
android:singleLine="true"
android:layout_marginLeft="10dp"
android:textSize="20sp"
android:textColor="#ffffff"
android:layout_alignBottom="@+id/tv_movie_item_img360"
android:layout_toEndOf="@+id/tv_movie_item_img"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""While exploring the uncharted wilderness in 1823, frontiersman Hugh Glass (Leonardo DiCaprio) sustains life-threatening injuries from a brutal bear attack."
android:id="@+id/tv_movie_item_details"
android:layout_marginLeft="10dp"
android:paddingRight="10dp"
android:textSize="12sp"
android:layout_marginTop="5dp"
android:layout_below="@+id/tv_movie_item_img360"
android:layout_toEndOf="@+id/tv_movie_item_img" />
<ExpandableListView
android:id="@+id/exListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/tv_movie_item_details"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</ExpandableListView>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_forum"
app:layout_anchor="@id/tv_movie_item_img360"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
FloatingActionButton myFab = (FloatingActionButton) myView.findViewById(R.id.fab);
myFab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
doMyThing();
}
});
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_open:
openFile(FILENAME);
return true;
case R.id.action_save:
saveFile(FILENAME);
return true;
default:
return true;
}
}
Когда пользователь выбирает пункт меню параметров (в том числе пункты действий из строки действий), система вызывает метод onOptionsItemSelected() вашей операции. Этот метод передает выбранный класс MenuItem. Идентифицировать пункт меню можно, вызвав метод getItemId(), который возвращает уникальный идентификатор пункта меню (определенный атрибутом android:id из ресурса меню или целым числом, переданным методу add()). Этот идентификатор можно сопоставить с известными пунктами меню, чтобы выполнить соответствующее действие.
<solid android:color="#FF0000" />
из шейпа.imgview.Background.SetColorFilter(Resources.GetColor(Resource.Color.blue), PorterDuff.Mode.Add);
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<color name="blue">#0000ff</color>
</resources>