我想知道如何在更改手机方向时修改视图.例如,当你按住手机"正常方式"时,我的应用程序工作正常,但当你将它移动到横向位置时,应用程序外观变得丑陋: - 如何确保壁纸不会与手机一起"转动" ,这是我的布局代码:文件名:list-event.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<ListView android:id="@android:id/list"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="@drawable/fon2"></ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
你可以看到它只是一个简单的列表,但我希望背景保持不变.我为布局和布局添加了相同的内容 - 我只是将同一个文件列为list_event,但我认为我需要为背景图像添加一些命令,以便以不同的方式进行定向.我希望你提前了解我写的内容
我有这个项目,我有一个比屏幕大小更大的位图.我想调整它以适应屏幕.我没有标题栏,而且我处于全屏模式.这是我的非工作代码:
public class ScopView extends View
{
private Scop thescop;
public ScopView(Context context, Scop newscop)
{
super(context);
this.thescop = newscop;
}
@Override
public void onDraw(Canvas canvas)
{
Bitmap scopeBitmap;
BitmapFactory.Options bfOptions = new BitmapFactory.Options();
bfOptions.inDither = false;
bfOptions.inPurgeable = true;
bfOptions.inInputShareable = true;
bfOptions.inTempStorage = new byte[32 * 1024];
scopeBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.scope, bfOptions);
scopeBitmap.createScaledBitmap(scopeBitmap, SniperActivity.Width, SniperActivity.Height, false);
canvas.drawBitmap(scopeBitmap, SniperActivity.scopx, SniperActivity.scopy, null);
}
}
Run Code Online (Sandbox Code Playgroud)
在这里使用createScaledBitmap方法时,我将自己用作源,并使用一个活动中的一些变量来从屏幕首选项中检索窗口高度和宽度.
在这里,我正在开发一个仅以横向模式播放视频的应用程序。我在 AndroidManifest.xml 文件中将活动方向设置为“横向”,并且我的视频播放得非常好,但问题是我将设备保持在横向模式,当我将设备旋转到 180 度时,我的视频播放是颠倒的(底部)到达顶点)。它不是按照这个变化的。
我试图实现这样的形象:

问题是当我在风景上并放置像图像的搜索栏时,软键盘覆盖所有屏幕,我想要的行为就像我试过的图像
android:windowSoftInputMode="adjustPan|adjustResize"
Run Code Online (Sandbox Code Playgroud)
并且似乎不起作用,至少在果冻豆上.有任何想法吗?谢谢
我的应用程序中有一个相对布局,但是当手机处于横向模式时,它不会滚动。我读到我需要将其放入 ScrollView 中,但我不断收到错误,所以我可能做得不对。
有小费吗?
提前致谢。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff8400"
android:orientation="vertical" >
<EditText
android:id="@+id/txt_nomeSpot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp"
android:ems="10"
android:hint="@string/nome"
android:inputType="text"
android:gravity="center" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/txt_coordSpot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_nomeSpot"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:hint="@string/coordenadas"
android:inputType="text"
android:ems="10"
android:gravity="center" />
<EditText
android:id="@+id/txt_classSpot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_coordSpot"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:hint="@string/classif"
android:inputType="text"
android:ems="10"
android:gravity="center" />
<EditText
android:id="@+id/txt_tipoSpot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_classSpot"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:hint="@string/tipo"
android:inputType="text"
android:ems="10"
android:gravity="center"/>
<EditText
android:id="@+id/txt_subtipoSpot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_tipoSpot"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:hint="@string/subtipo"
android:inputType="text"
android:ems="10"
android:gravity="center" />
<EditText
android:id="@+id/txt_moradaSpot"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 有没有一种简单的方法可以在不影响桌面设备的情况下定位横向移动设备,而无需输入每个设备的屏幕尺寸?
如果没有,是否有针对大多数用户的单一最佳解决方案?
现在移动屏幕的分辨率可以等于或高于大多数桌面屏幕,我不明白为什么许多人使用低于 640x480 的分辨率规则。
例如,要定位纵向设备(99% 是移动设备),可以将规则写入
/*Global and desktop rules*/
@media only screen and (orientation: portrait) {
/*Mobile overwrites*/
}
Run Code Online (Sandbox Code Playgroud)
但是,相同的查询orientation: landscape也会影响桌面用户。
我的临时解决方法是使用vw,vh和vmin,但我想知道是否有更好的方法。
请问一个mobileCSS媒体简化Web开发人员的工作?
我需要在横向和纵向上为 iPad 制作不同的布局,但 iPad 上的尺寸类别始终是常规/常规。Apple 推荐的调整界面的方法是使用具有尺寸类别的自适应布局,但在 iPad 上,纵向和横向模式没有区别。
有没有办法在iPad上呈现不同的纵向和横向布局而不检测设备方向?
例如,在 iPhone(紧凑/常规)上将显示为:
因此,我们的目标是在 iPad 处于纵向模式时显示 iPhone 布局。
谢谢!
我一直在尝试在横向模式下开发一个应用程序,所以我在我的Manifest中放置了"android:screenOrientation ="landscape.它工作得很好,但是,我的xml文件的图形布局仍然没有处于横向模式,所以我无法设计我的用户界面很好.有什么帮助吗?谢谢
我从照片库获取图片,并使用以下代码将其称为图片:
@IBAction func importImage(_ sender: AnyObject) {
let image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.photoLibrary
image.allowsEditing = false
self.present(image, animated: true) { }
}
Run Code Online (Sandbox Code Playgroud)
和此代码:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
myImageView.image = image
dismiss(animated: true, completion: nil)
SubmitBtnOutlet.isHidden = false;
Gurpcontroller.person = "yours";
Gurpcontroller.collecterthing = "Coin";
PictureViewController.imageuniversal = myImageView
} else {
//Error message
}
}
Run Code Online (Sandbox Code Playgroud)
我想看看图像是风景还是肖像。然后,如果它是风景,我想将其更改为肖像。