下面列出了android.view.View#getLayoutDirection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void update(View anchor, WindowManager.LayoutParams params) {
final int layoutDirection = anchor != null ? anchor.getLayoutDirection()
: View.LAYOUT_DIRECTION_LOCALE;
mWindowPresenter.show(params, getTransitionEpicenter(), isLayoutInsetDecor(),
layoutDirection);
}
@SuppressLint("NewApi")
static int getLayoutDirection(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return v.getLayoutDirection();
}
return View.LAYOUT_DIRECTION_LTR;
}
@Thunk private void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
CellLayout layout = (CellLayout) host.getParent().getParent();
layout.markCellsAsUnoccupiedForView(host);
if (action == R.string.action_increase_width) {
if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)
&& layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY))
|| !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
lp.cellX --;
info.cellX --;
}
lp.cellHSpan ++;
info.spanX ++;
} else if (action == R.string.action_decrease_width) {
lp.cellHSpan --;
info.spanX --;
} else if (action == R.string.action_increase_height) {
if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
lp.cellY --;
info.cellY --;
}
lp.cellVSpan ++;
info.spanY ++;
} else if (action == R.string.action_decrease_height) {
lp.cellVSpan --;
info.spanY --;
}
layout.markCellsAsOccupiedForView(host);
Rect sizeRange = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, sizeRange);
((LauncherAppWidgetHostView) host).updateAppWidgetSize(null,
sizeRange.left, sizeRange.top, sizeRange.right, sizeRange.bottom);
host.requestLayout();
mLauncher.getModelWriter().updateItemInDatabase(info);
announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
}
/**
* Returns true if view's layout direction is right-to-left.
*
* @param view the View whose layout is being considered
*/
public static boolean isLayoutRtl(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
} else {
// All layouts are LTR before JB MR1.
return false;
}
}
@SuppressLint("NewApi")
static int getLayoutDirection(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return v.getLayoutDirection();
}
return View.LAYOUT_DIRECTION_LTR;
}
@Thunk void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
CellLayout layout = (CellLayout) host.getParent().getParent();
layout.markCellsAsUnoccupiedForView(host);
if (action == R.string.action_increase_width) {
if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)
&& layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY))
|| !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
lp.cellX --;
info.cellX --;
}
lp.cellHSpan ++;
info.spanX ++;
} else if (action == R.string.action_decrease_width) {
lp.cellHSpan --;
info.spanX --;
} else if (action == R.string.action_increase_height) {
if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
lp.cellY --;
info.cellY --;
}
lp.cellVSpan ++;
info.spanY ++;
} else if (action == R.string.action_decrease_height) {
lp.cellVSpan --;
info.spanY --;
}
layout.markCellsAsOccupiedForView(host);
Rect sizeRange = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, sizeRange);
((LauncherAppWidgetHostView) host).updateAppWidgetSize(null,
sizeRange.left, sizeRange.top, sizeRange.right, sizeRange.bottom);
host.requestLayout();
LauncherModel.updateItemInDatabase(mLauncher, info);
announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
}
@SuppressWarnings("")
public static int getLayoutDirection(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return v.getLayoutDirection();
}
return View.LAYOUT_DIRECTION_LTR;
}
/**
* Returns true if view's layout direction is right-to-left.
*
* @param view the View whose layout is being considered
*/
public static boolean isLayoutRtl(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
} else {
// All layouts are LTR before JB MR1.
return false;
}
}
private static boolean isLayoutRtl(View view) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
} else {
// All layouts are LTR before JB MR1.
return false;
}
}
public static int getLayoutDirection(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return v.getLayoutDirection();
}
return View.LAYOUT_DIRECTION_LTR;
}
public static boolean isLayoutRtl(View view) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
return View.LAYOUT_DIRECTION_RTL == view.getLayoutDirection();
} else {
return false;
}
}
/**
* 23 * Returns true if view's layout direction is right-to-left.
* 24 *
* 25 * @param view the View whose layout is being considered
* 26
*/
public static boolean isLayoutRtl(View view) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
} else {
// All layouts are LTR before JB MR1.
return false;
}
}
private static float getSignFromDirection(@NonNull View view) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -1f : 1f;
}
public static int getLayoutDirection(View view) {
if (Build.VERSION.SDK_INT >= 17) {
return view.getLayoutDirection();
}
return View.LAYOUT_DIRECTION_LTR;
}
@Override
public boolean isRtl(@NonNull View view) {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static int getLayoutDirection(View v) {
return C.API_JELLY_BEAN_MR1 ? v.getLayoutDirection() : 0;
}
public static int b(View view)
{
return view.getLayoutDirection();
}
public static int getLayoutDirection(View view) {
return view.getLayoutDirection();
}
public static int getLayoutDirection(View view) {
return view.getLayoutDirection();
}
public static int getLayoutDirection(View view) {
return view.getLayoutDirection();
}