我有一个应该显示在某些图像上的特定位置的视图,我已经使用AbsoluteLayout做了,但我不想使用它,我试图用FrameLayout获得相同的结果.
但我不能让这个工作,这是我的两次尝试:
public void showVideo(RectF bounds) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) video.getLayoutParams();
params.width = (int) bounds.width();
params.height = (int) bounds.height();
int x = (int) viewer.getPageXOffset();
int y = (int) viewer.getPageYOffset();
video.setPadding((int) (x + bounds.left), (int) (y + bounds.top), (int) (x + bounds.right),
(int) (y + bounds.bottom));
video.setLayoutParams(params);
video.invalidate();
video.setVisibility(View.VISIBLE);
video.setFocusable(true);
video.setFocusableInTouchMode(true);
video.requestFocus();
}
Run Code Online (Sandbox Code Playgroud)
和:
public void showVideo(RectF bounds, final String videoUrl) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) video.getLayoutParams();
params.width = (int) bounds.width();
params.height = (int) bounds.height();
int x = (int) (viewer.getPageXOffset() …Run Code Online (Sandbox Code Playgroud) 如何在Android上打开PopupWindow并让所有其他组件都可以触摸而不会忽略PopupWindow?
这就是它的创建方式:
public class DynamicPopup {
private final PopupWindow window;
private final RectF rect;
private final View parent;
private final RichPageView view;
public DynamicPopup(Context context, RichPage page, RectF rectF, View parent) {
this.parent = parent;
rect = rectF;
window = new PopupWindow(context);
window.setBackgroundDrawable(new BitmapDrawable());
window.setWidth((int) rect.width());
window.setHeight((int) rect.height());
window.setTouchable(true);
window.setFocusable(true);
window.setOutsideTouchable(true);
view = new RichPageView(context, page, false);
window.setContentView(view);
view.setOnCloseListener(new Listener(){
@Override
public void onAction() {
window.dismiss();
}
});
}
public void show() {
window.showAtLocation(parent, Gravity.NO_GRAVITY, (int) rect.left, (int) rect.top);
} …Run Code Online (Sandbox Code Playgroud) 我正在创建一个可重复使用的加载屏幕以在活动之间使用,在LoadingActivity上我添加了一个半透明的背景资源,但是我无法看到旧的活动.
public class LoadingActivity extends Activity {
public static int REQUEST_LOADING_SCREEN = 40;
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
FrameLayout mainLayout = new FrameLayout(this);
mainLayout.setBackgroundResource(R.drawable.background_translucent);
LinearLayout layout = new LinearLayout(this);
layout.setGravity(Gravity.CENTER);
LayoutParams params = LayoutParamsFactory.newMatchFrameLP();
params.gravity = Gravity.CENTER;
mainLayout.addView(layout, params);
ProgressBar bar = new ProgressBar(this);
bar.setIndeterminate(true);
layout.addView(bar, LayoutParamsFactory.newWrapLinearLP());
TextView text = new TextView(this);
text.setText("Loading...");
layout.addView(text, LayoutParamsFactory.newWrapLinearLP());
setContentView(mainLayout);
}
public static void openFor(Activity activity) {
Intent intent = new Intent(activity, LoadingActivity.class);
activity.startActivityForResult(intent, REQUEST_LOADING_SCREEN);
}
public static void closeFrom(Activity activity) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试为android编译本机程序.
但是当运行ndk-build命令时,我得到了以下结果.
/home/marcos/dev/workspace/rmsdk.native.wraper/jni/include-all/uft_alloc.h:26:21: error: stdexcept: No such file or directory
/home/marcos/dev/workspace/rmsdk.native.wraper/jni/include-all/uft_alloc.h:27:18: error: limits: No such file or directory
Run Code Online (Sandbox Code Playgroud)
stdexcept和limits是std C++ lib的一部分.
这是我的Android.mk
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(MY_PATH)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := rmsdk
LOCAL_SRC_FILES := curlnetprovider.cpp RMServices.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all
LOCAL_STATIC_LIBRARIES := adept cryptopenssl curl dp expat fonts hobbes jpeg mschema png t3 xml zlib
include $(BUILD_SHARED_LIBRARY)
Run Code Online (Sandbox Code Playgroud)
我应该明确告诉它它是一个C++源代码?
我已经知道如何在Android上将我的Activity作为全屏,现在我需要在此屏幕中绘制一个图像.
这是我的XML布局.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/image01" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
此图像是动态生成的,并在ImageView中绘制.
这是我的活动代码.
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
Run Code Online (Sandbox Code Playgroud)
但是在运行时,Activity是FullScreen,但ImageView在中心调整.
怎么了?
我添加了以下代码以查看组件尺寸.
View view = getWindow().getDecorView();
Log.i("RMSDK:J:IbaReader(decor)",
"[w=" + view.getWidth() + ":h=" + view.getHeight() + "]");
Log.i("RMSDK:J:IbaReader(img)",
"[w=" + img.getWidth() + ":h=" + img.getHeight() + "]");
Run Code Online (Sandbox Code Playgroud)
这导致两种情况下[w = 320:h = 480].
这是我的绘制方法.
private void draw() {
byte[] image = services.getImageBuffer(600, 1024);
Bitmap bmp = Bitmap.createBitmap(600, 1024, Bitmap.Config.RGB_565);
int row = …Run Code Online (Sandbox Code Playgroud) 在为最新版本更新SDK和ADT之后,我尝试运行我的应用程序并且Eclipse记录以下错误:
[- RichReaderDemo] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lbr/com/digitalpages/renderer/NewReaderActivity;
[- RichReaderDemo] Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[- RichReaderDemo] Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[- RichReaderDemo] Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[- RichReaderDemo] Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[- RichReaderDemo] Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[- RichReaderDemo] Dx at com.android.dx.command.dexer.Main.run(Main.java:206)
[- RichReaderDemo] Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[- RichReaderDemo] Dx …Run Code Online (Sandbox Code Playgroud) 我最近在用我的 Github 帐户登录的 gitlab 上创建了一个项目。
但是当使用 gitbash 克隆项目(将我当前的 ssh-key 添加到 gitlab 帐户)时,shell 会提示输入用户名/密码,从 github 输入我的用户名和密码会导致身份验证失败。(电子邮件/密码也失败)
我做错了什么?
我正在尝试将HTML5页面嵌入到我的应用程序中.
内容大于设备,所以我用它来缩放:
web.setInitialScale((int) (728 / 600 * 100)); //728 is the height of the page, 600 of the device
Run Code Online (Sandbox Code Playgroud)
这样屏幕尺寸正确,但内容太小,我需要对其进行缩放控制.我尝试了WebView的supportZoom(true),缩放IN是正确的,但是当缩小时,这不会达到我的初始比例.
我最近重构了一个应用程序,并替换了一个FrameFayip,用于我在Fragments之间交换的FrameLayout.
每次用户请求其中一个视图:
public void showLibraryOf(long publisherId) {
library = new DownloadLibraryFragment(id, viewFactory());
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.container, library);
ft.commit();
library.setAdapterObserver(this);
}
public void showMyLibraryOf(long publisherId) {
myLibrary = new MyLibraryFragment(id, viewFactory());
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.container, myLibrary);
ft.commit();
}
public void showHelp() {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.container, new HelpFragment());
ft.commit();
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个新片段并替换旧片段.从屏幕上删除的那些被调用onDestroy,但是我在屏幕上加载的位图消耗的内存不会被删除,因此应用程序在片段之间进行一些交换后崩溃.
我还尝试删除onDestroy中的引用
@Override
public void onDestroyView() {
destroy();
super.onDestroyView();
adapter.clear();
adapter.clearObservers();
adapter.notifyDataSetChanged();
view.setAdapter(new ArrayAdapter<Journal>(getActivity(), 0));
adapter = null;
view = null;
}
Run Code Online (Sandbox Code Playgroud)
但记忆力不断增长.
谁知道任何解决方案?也许重用片段?有效地摧毁它?我在听.
我想知道哪些是Eclipse导航键盘快捷键.
我已经用过:
Ctrl+ Shift+ UP或DOWN导航槽方法
Ctrl+ ,或.在错误之间导航
Ctrl+ Page UP或DOWN在标签之间导航
UP或者DOWN在"Package Explorer"中导航项目结构并SPACE展开/折叠文件夹或打开文件
有了那些我几乎不使用鼠标,我想知道是否有一个快捷方式在日食内部窗口之间交换(到控制台底部,代码中间,任务权限,资源管理器左侧等)
谢谢
android ×8
java ×2
android-ndk ×1
eclipse ×1
eclipse-adt ×1
gitlab ×1
imageview ×1
memory-leaks ×1
navigation ×1
popupwindow ×1
webview ×1