本文整理汇总了Java中android.view.View.getLayoutDirection方法的典型用法代码示例。如果您正苦于以下问题:Java View.getLayoutDirection方法的具体用法?Java View.getLayoutDirection怎么用?Java View.getLayoutDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getLayoutDirection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performResizeAction
import android.view.View; //导入方法依赖的package包/类
@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));
}
示例2: getLayoutDirection
import android.view.View; //导入方法依赖的package包/类
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;
}
示例3: convertGravity
import android.view.View; //导入方法依赖的package包/类
private static int convertGravity(View view, int gravity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
boolean isRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
if (gravity == Gravity.START) {
gravity = isRtl ? Gravity.RIGHT : Gravity.LEFT;
} else if (gravity == Gravity.END) {
gravity = isRtl ? Gravity.LEFT : Gravity.RIGHT;
}
}
return gravity;
}
示例4: getLayoutDirection
import android.view.View; //导入方法依赖的package包/类
@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;
}
示例5: isLayoutRtl
import android.view.View; //导入方法依赖的package包/类
/**
* 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;
}
}
示例6: getLayoutDirection
import android.view.View; //导入方法依赖的package包/类
public static int getLayoutDirection(View view) {
return view.getLayoutDirection();
}
示例7: performResizeAction
import android.view.View; //导入方法依赖的package包/类
@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));
}
示例8: createRelativeInsetDrawable
import android.view.View; //导入方法依赖的package包/类
/**
* Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
* of {@code view}.
*/
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
int insetStart, int insetTop, int insetEnd, int insetBottom, View view) {
boolean isRtl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
&& view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
isRtl);
}