Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JAVA
  2. ActionBar actionBar = getSupportActionBar();
  3.         if (actionBar != null) {
  4.             actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  5.             // Custom ActionBar
  6.             View customView = LayoutInflater.from(this).inflate(
  7.                     R.layout.actionbar_title, null);
  8.             TextView tv = (TextView) customView.findViewById(R.id.custom_title);
  9.             tv.setText("基本情報取込");
  10.             // Set ActionBar properties
  11.             ActionBar.LayoutParams params = new ActionBar.LayoutParams(
  12.                     ActionBar.LayoutParams.MATCH_PARENT,
  13.                     ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
  14.             actionBar.setCustomView(customView, params);
  15.             actionBar.setDisplayHomeAsUpEnabled(true);
  16.         }
  17.  
  18. //XML
  19. <?xml version="1.0" encoding="utf-8"?>
  20. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  21.     android:layout_width="match_parent"
  22.     android:layout_height="match_parent" >
  23.  
  24.     <TextView
  25.         android:id="@+id/custom_title"
  26.         android:layout_width="match_parent"
  27.         android:layout_height="match_parent"
  28.         android:gravity="center"
  29.         android:ellipsize="end"
  30.         android:maxLines="1"
  31.         android:textAppearance="?android:attr/textAppearanceMedium"
  32.         android:textColor="@android:color/white" />
  33.  
  34. </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement