本文整理了Java中android.support.v4.app.FragmentActivity.getTheme()
方法的一些代码示例,展示了FragmentActivity.getTheme()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentActivity.getTheme()
方法的具体详情如下:
包路径:android.support.v4.app.FragmentActivity
类名称:FragmentActivity
方法名:getTheme
暂无
代码示例来源:origin: k9mail/k-9
private void setBackgroundColor(View view, boolean selected, boolean read) {
if (selected || K9.useBackgroundAsUnreadIndicator()) {
int res;
if (selected) {
res = R.attr.messageListSelectedBackgroundColor;
} else if (read) {
res = R.attr.messageListReadItemBackgroundColor;
} else {
res = R.attr.messageListUnreadItemBackgroundColor;
}
TypedValue outValue = new TypedValue();
fragment.getActivity().getTheme().resolveAttribute(res, outValue, true);
view.setBackgroundColor(outValue.data);
} else {
view.setBackgroundColor(Color.TRANSPARENT);
}
}
代码示例来源:origin: k9mail/k-9
private void changeBackgroundColorIfActiveMessage(Cursor cursor, Account account, View view) {
String uid = cursor.getString(UID_COLUMN);
String folderServerId = cursor.getString(FOLDER_SERVER_ID_COLUMN);
if (account.getUuid().equals(fragment.activeMessage.getAccountUuid()) &&
folderServerId.equals(fragment.activeMessage.getFolderServerId()) &&
uid.equals(fragment.activeMessage.getUid())) {
int res = R.attr.messageListActiveItemBackgroundColor;
TypedValue outValue = new TypedValue();
fragment.getActivity().getTheme().resolveAttribute(res, outValue, true);
view.setBackgroundColor(outValue.data);
}
}
代码示例来源:origin: sjwall/MaterialTapTargetPrompt
@NonNull
@Override
public Resources.Theme getTheme()
{
return this.fragment.requireActivity().getTheme();
}
代码示例来源:origin: YoKeyword/SwipeBackFragment
protected int getWindowBackground() {
TypedArray a = getActivity().getTheme().obtainStyledAttributes(new int[]{
android.R.attr.windowBackground
});
int background = a.getResourceId(0, 0);
a.recycle();
return background;
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
private int getListPreferredItemHeight() {
final TypedValue typedValue = new TypedValue();
// Resolve list item preferred height theme attribute into typedValue
getActivity().getTheme().resolveAttribute(
android.R.attr.listPreferredItemHeight, typedValue, true);
// Create a new DisplayMetrics object
final DisplayMetrics metrics = new DisplayMetrics();
// Populate the DisplayMetrics
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// Return theme value based on DisplayMetrics
return (int) typedValue.getDimension(metrics);
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
private int getListPreferredItemHeight() {
final TypedValue typedValue = new TypedValue();
// Resolve list item preferred height theme attribute into typedValue
getActivity().getTheme().resolveAttribute(
android.R.attr.listPreferredItemHeight, typedValue, true);
// Create a new DisplayMetrics object
final DisplayMetrics metrics = new DisplayMetrics();
// Populate the DisplayMetrics
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// Return theme value based on DisplayMetrics
return (int) typedValue.getDimension(metrics);
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
private int getListPreferredItemHeight() {
final TypedValue typedValue = new TypedValue();
getActivity().getTheme().resolveAttribute(
android.R.attr.listPreferredItemHeight, typedValue, true);
final DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
return (int) typedValue.getDimension(metrics);
}
代码示例来源:origin: bilibili/BiliShare
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// use alert Dialog Theme here
final TypedValue outValue = new TypedValue();
getActivity().getTheme().resolveAttribute(android.R.attr.alertDialogTheme, outValue, true);
int theme = outValue.resourceId;
setStyle(STYLE_NORMAL, theme);
}
代码示例来源:origin: YoKeyword/SwipeBackFragment
public void attachToActivity(FragmentActivity activity) {
mActivity = activity;
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
android.R.attr.windowBackground
});
int background = a.getResourceId(0, 0);
a.recycle();
ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
decorChild.setBackgroundResource(background);
decor.removeView(decorChild);
addView(decorChild);
setContentView(decorChild);
decor.addView(this);
}
代码示例来源:origin: ManbangGroup/Phantom
@Override
public Resources.Theme getTheme() {
if (mUseHostTheme) {
initHostTheme();
return mHostTheme;
}
return null == mClientActivity ? super.getTheme() : mClientActivity.getTheme();
}
代码示例来源:origin: xbmc/Kore
public PlayListAdapter(List<ListType.ItemsAll> playlistItems) {
super();
this.playlistItems = playlistItems;
Resources.Theme theme = getActivity().getTheme();
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {
R.attr.appCardBackgroundColor,
R.attr.appSelectedCardBackgroundColor});
Resources resources = getResources();
cardBackgroundColor =
styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.dark_content_background));
selectedCardBackgroundColor =
styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.dark_selected_content_background));
styledAttributes.recycle();
}
代码示例来源:origin: franmontiel/FullScreenDialog
private void setThemeBackground(View view) {
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
view.setBackgroundColor(a.data);
} else {
try {
Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId, getActivity().getTheme());
ViewCompat.setBackground(view, d);
} catch (Resources.NotFoundException ignore) {
}
}
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
/**
* Gets the preferred height for each item in the ListView, in pixels, after accounting for
* screen density. ImageLoader uses this value to resize thumbnail images to match the ListView
* item height.
*
* @return The preferred height in pixels, based on the current theme.
*/
private int getListPreferredItemHeight() {
final TypedValue typedValue = new TypedValue();
// Resolve list item preferred height theme attribute into typedValue
getActivity().getTheme().resolveAttribute(
android.R.attr.listPreferredItemHeight, typedValue, true);
// Create a new DisplayMetrics object
final DisplayMetrics metrics = new DisplayMetrics();
// Populate the DisplayMetrics
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// Return theme value based on DisplayMetrics
return (int) typedValue.getDimension(metrics);
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
/**
* Gets the preferred height for each item in the ListView, in pixels, after accounting for
* screen density. ImageLoader uses this value to resize thumbnail images to match the ListView
* item height.
*
* @return The preferred height in pixels, based on the current theme.
*/
private int getListPreferredItemHeight() {
final TypedValue typedValue = new TypedValue();
// Resolve list item preferred height theme attribute into typedValue
getActivity().getTheme().resolveAttribute(
android.R.attr.listPreferredItemHeight, typedValue, true);
// Create a new DisplayMetrics object
final DisplayMetrics metrics = new DisplayMetrics();
// Populate the DisplayMetrics
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// Return theme value based on DisplayMetrics
return (int) typedValue.getDimension(metrics);
}
代码示例来源:origin: hefuyicoder/ZhihuDaily
public void refreshUI() {
TypedValue headerBackground = new TypedValue();
TypedValue navdrawerBackground = new TypedValue();
TypedValue navdrawerTextColor = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
theme.resolveAttribute(R.attr.colorPrimaryDark, headerBackground, true);
theme.resolveAttribute(R.attr.navdrawer_background, navdrawerBackground,true);
theme.resolveAttribute(R.attr.navdrawer_text_color, navdrawerTextColor, true);
recyclerView.setBackgroundResource(navdrawerBackground.resourceId);
int childCount = recyclerView.getChildCount();
for (int childIndex = 0; childIndex < childCount; childIndex++) {
int viewType = mAdapter.getItemViewType(childIndex);
switch (viewType) {
case NavigationDrawerAdapter.Type.TYPE_HEADER:
ViewGroup header = (ViewGroup) recyclerView.getChildAt(childIndex);
header.setBackgroundResource(headerBackground.resourceId);
break;
case NavigationDrawerAdapter.Type.TYPE_ITEM:
ViewGroup item = (ViewGroup) recyclerView.getChildAt(childIndex);
TextView textView = (TextView) item.findViewById(R.id.tvItemName);
textView.setTextColor(navdrawerTextColor.resourceId);
break;
case NavigationDrawerAdapter.Type.TYPE_BOTTOM_SPACE:
View childView = recyclerView.getChildAt(childIndex);
childView.setBackgroundResource(navdrawerBackground.resourceId);
break;
}
}
mAdapter.notifyDataSetChanged();
}
代码示例来源:origin: hefuyicoder/ZhihuDaily
TypedValue itemStoryBackground = new TypedValue();
TypedValue windowBackground = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
theme.resolveAttribute(R.attr.item_story_text_color, itemStoryTextColor, true);
theme.resolveAttribute(R.attr.item_story_background_color, itemStoryBackground, true);
代码示例来源:origin: xbmc/Kore
TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(new int[] {
R.attr.iconFastForward,
R.attr.iconRewind,
代码示例来源:origin: rumboalla/apkupdater
@AfterViews
protected void onInit(
) {
mAppNameText.setTextColor(ColorUtil.getColorFromTheme(getActivity().getTheme(), R.attr.colorAccent));
mAppNameText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DownloadUtil.launchBrowser(getContext(), Constants.GitHubURL);
}
});
try {
WebView v = getWebView();
ViewCompat.setNestedScrollingEnabled(v, true);
mTextContainer.addView(v);
} catch (Exception e) {
try {
TextView v = getTextView();
ViewCompat.setNestedScrollingEnabled(v, true);
mTextContainer.addView(v);
} catch (Exception ignored) {
}
}
}
代码示例来源:origin: zendesk/sdk_demo_app_android
@Override
public void onStart() {
super.onStart();
AppStorage storage = Global.getStorage(getContext());
UserProfile userProfile = storage.getUserProfile();
if (userProfile.getUri() != null) {
ImageUtils.loadProfilePicture(getContext(), userProfile.getUri(), imageView);
}
userName.setText(userProfile.getName());
email.setText(userProfile.getEmail());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
userName.setTextColor(getResources().getColor(R.color.primaryTextColor, getActivity().getTheme()));
email.setTextColor(getResources().getColor(R.color.primaryTextColor, getActivity().getTheme()));
}
}
}
代码示例来源:origin: rumboalla/apkupdater
@UiThread(propagation = UiThread.Propagation.REUSE)
void initProgressBar(
) {
try {
mLoader.getIndeterminateDrawable().setColorFilter(
ColorUtil.getColorFromTheme(getActivity().getTheme(), R.attr.colorAccent),
android.graphics.PorterDuff.Mode.MULTIPLY
);
setProgressBarProgress(mProgressCount, mProgressMax);
if (mProgressMax == 0 && mProgressCount == 0) {
setProgressBarVisibility(GONE);
} else {
setProgressBarVisibility(VISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!