我构建了Android应用程序,现在想添加不同方向的布局。我创建了一个布局区域文件夹,并为我的第一个入门活动“ myStartActivity”(与之前在两个方向上使用的布局名称相同)放置了一个不同的布局。
根据我的屏幕方向,在我启动该应用之前,应选择正确的布局:当我纵向启动时,从“布局”文件夹中选择“ myLayout.xml”,而从“布局-土地”中选择“ myLayout.xml”-我在风景中开始时的文件夹。
问题是,当我已经在活动中时旋转设备时,旋转后我没有得到新的布局。例如:从纵向旋转到横向,静止图像从“布局”文件夹而不是“布局土地”文件夹显示“ myLayout.xml”。
我没有覆盖任何OnConfigurationChange方法或任何东西。我在“ myStartActivity”中所做的只是实例化一些按钮,并为它们提供了一些侦听器。我想在横向中使用其他布局来更改按钮的顺序。
android landscape portrait screen-orientation device-orientation
我已经开始使用jquery移动框架但我似乎无法使用横向和纵向类来缩小样式.
文件说
HTML元素将始终具有"纵向"或"横向"类,具体取决于浏览器或设备的方向.
所以我的印象是,<h1>foo</h1>要么是<h1 class="landscape">foo</h1>或<h1 class="portrait">foo</h1>
但h1.landscape { font-size:16px; }并h1.portrait { font-size:9px; }似乎不工作.
如果有人能够对此有所启发,我将不胜感激.
我必须在标题和背景上添加图像.是否可以根据屏幕方向(纵向和横向)自动调整图像大小.我以纵向分辨率设置图像,但当我将屏幕更改为横向时,图像未调整大小.谁能给我一些指导方针?
以下代码显示了垂直摄像头的预览,它的工作原理..但是!我在风景中得到了一张照片!:(
我如何垂直构建它?我在垂直方向上有预览视图,但我无法垂直保存图片.
问候和感谢,弗兰
ONCLICK
public void onClick(View arg0) {
camera.takePicture(myShutterCallback, myPictureCallback_RAW, myPictureCallback_JPG);
}
Run Code Online (Sandbox Code Playgroud)
预习
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
if (previewing) {
camera.stopPreview();
previewing = false;
}
if (camera != null) {
/*
* camera.setPreviewDisplay(surfaceHolder); camera.startPreview();
* previewing = true;
*/
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(width, height);
camera.setParameters(parameters);
// Condicions per utilitzar la orientacio adecuada segons el sdk
if (Integer.parseInt(Build.VERSION.SDK) >= 8)
setDisplayOrientation(camera, 90);
else {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
parameters.set("orientation", "portrait"); …Run Code Online (Sandbox Code Playgroud) 我为一个活动指定了两个单独的布局xml文件,一个用于res/layout文件夹中的Portrait,另一个用于res/layout-land文件夹中的Landscape.我的实际问题是,当我以纵向模式启动应用程序时,它需要ui从布局和即时我旋转我的手机它不需要从布局 - 土地文件夹中的xml它需要从布局文件夹ui,如果我在横向模式下启动我的应用程序它从layout-land文件夹中获取xml并立即将我旋转到肖像模式它从布局中获取xml-land ui不会更改为纵向ui.
可以任何伙伴告诉我什么是问题是有什么需要的PLZ帮助我解决这个问题.
提前致谢 .
this is my landscape ui xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget57"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_gravity="center|center_vertical"
android:layout_marginTop="30dp"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp" >
<TextView
android:id="@+id/txtName"
android:layout_width="90dp"
android:text="@string/UserName" />
<EditText
android:id="@+id/edName"
android:imeOptions="actionNext|actionDone"
android:paddingRight="10dp"
android:singleLine="true"
android:width="240dp" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/txtPass"
android:layout_width="90dp"
android:text="@string/PassWord" />
<EditText
android:id="@+id/edPass"
android:imeOptions="actionGo"
android:paddingRight="10dp"
android:password="true"
android:singleLine="true"
android:width="240dp" />
</TableRow>
<LinearLayout
android:id="@+id/widget57"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/btnLogin"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="@string/btn_GO"
android:textSize="19sp" >
</Button> …Run Code Online (Sandbox Code Playgroud) 我尝试了不同的width&组合,device-width但是在横向上这个代码永远不会把背景变成红色;
当我有多个媒体查询时,我遇到了问题.看到这个JSfiddle示例,除非删除最后一个媒体查询,否则div背景永远不会是绿色
这就是我想要的3个不同媒体查询的目标:
- 智能手机和平板电脑(仅限肖像).这将是我拥有响应式布局的所有通用样式的地方
- 宽度:320px - 479px - 这将适用于小屏幕,例如仅限肖像的iphone
- 宽度:480px - 640px - 这将适用于较大的屏幕,如横向的iphone和纵向的ipad.不是风景中的ipad.
请注意,这是针对HTML电子邮件的,因此无法使用JS.
@media only screen and (max-width: 640px) {
body { padding: 10px !important }
}
/* Small screen */
@media only screen and (min-device-width: 320px) and (max-device-width: 479px) {
body { background: blue !important }
}
/* iPhone landscape and iPad portrait */
@media only screen and (max-device-width: 480px) and (max-device-width: 640px) {
body {
background: red !important
-webkit-text-size-adjust:none;
} …Run Code Online (Sandbox Code Playgroud) 我的肖像应用程序底部有一个智能横幅.
我的布局看起来像这样:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp">
<TextSwitcher
...
Some TextSwitcher Stuff Here
... />
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/bannerAd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:visibility="visible"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="@string/admobId" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的清单有适当的权限,这个:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
Run Code Online (Sandbox Code Playgroud)
我的广告由以下代码初始化:
private void initialiseAds()
{
AdView adView = (AdView) findViewById(R.id.bannerAd);
adView.setAdListener(new MyAdListener(adView));
AdRequest adRequest = new AdRequest();
adRequest.addKeyword("games");
adRequest.addKeyword("tabletop games");
adRequest.addKeyword("board games");
adRequest.addKeyword("monopoly");
adRequest.addKeyword("gambling");
adRequest.addKeyword("dice");
final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
adRequest.addTestDevice(deviceId);
adView.loadAd(adRequest);
}
Run Code Online (Sandbox Code Playgroud)
当我运行该应用时,我的广告不会显示.LogCat给了我这个:
08-01 11:24:59.015: E/Ads(10436): Not enough space to …Run Code Online (Sandbox Code Playgroud) 根据apple,我的应用程序必须能够以两种肖像模式运行.如何使用shouldAutorotateToInterfaceOrientation完成此操作?
我有一个活动,在活动启动时,我需要在lanscape中更改方向,然后我想在用户旋转设备时处理两个方向更改,但是一旦改变方向,稍后就不会改变方向.这是我的代码请帮忙
public class Hls extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hls);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.v("new orientation", "yes");
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
{
Toast.makeText(this, "portrait", Toast.LENGTH_LONG).show();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
Toast.makeText(this, "landscape", Toast.LENGTH_LONG).show();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 ubuntu 20.04 系统,所以如果我将屏幕更改为纵向,触摸效果不佳。看起来X和Y颠倒了。
有人知道发生了什么事吗?
portrait ×10
landscape ×6
android ×5
orientation ×2
admob ×1
ads ×1
banner ×1
coding-style ×1
css ×1
ipad ×1
iphone ×1
jquery ×1
jquery-ui ×1
photo ×1
screen ×1
take ×1
touchscreen ×1
ubuntu-20.04 ×1
xcode ×1