当前位置: 代码迷 >> Android >> 三无人员求指导啊解决办法
  详细解决方案

三无人员求指导啊解决办法

热度:35   发布时间:2016-05-01 21:20:18.0
三无人员求指导啊
小弟我是无基础,无经验,无天赋的三无人员,现在在学android开发,我想问两个问题,好吗?
1.我往drawable里面放的三张图片怎么显示的只有两张,那张LOGO的图片咋显示不鸟
下面是layout下main.xml的代码截图:[code=XML][/code]<?xml version="1.0" encoding="utf-8"?>
  <LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/layout"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/ver"
  android:layout_marginTop="15dip"
  android:layout_marginLeft="15dip">
  </ImageView>
 <RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/logo"
  android:layout_centerInParent="true">
  </ImageView>

 <ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/dev"
  android:layout_alignParentBottom="true"
  android:layout_alignParentRight="true"
  android:layout_marginRight="5dip"
  android:layout_marginBottom="35dip">
  </ImageView>
 </RelativeLayout>
</LinearLayout>
问题2:
当在模拟器运行上面的UI时,只有黑白两色,我在drawable里面放入了一张背景图,就寻思着显示背景色,所以在网上找资料,写了两个方法,但是我把这两个方法放在mainactivity里面的,运行出来控制台总提示androidhelper con't be resolved.下面是代码[code=Java][/code]package com.yarin.Android.MySinaWeibo;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
  /** Called when the activity is first created. */
  public static int ScreenOrient(Activity activity)
  {
  int orient = activity.getRequestedOrientation(); 
  if(orient != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && orient != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
  //宽>高为横屏,反正为竖屏 
  WindowManager windowManager = activity.getWindowManager(); 
  Display display = windowManager.getDefaultDisplay(); 
  int screenWidth = display.getWidth(); 
  int screenHeight = display.getHeight(); 
  orient = screenWidth < screenHeight ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
  return orient;
 }
  public static void AutoBackground(Activity activity,View view,int Background_v, int Background_h)
  {
  int orient=ScreenOrient(activity);
  if (orient == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { //纵向 
  view.setBackgroundResource(Background_v);
  }else{ //横向
  view.setBackgroundResource(Background_h);
  } 
  }
 
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  LinearLayout layout=(LinearLayout)findViewById(R.id.layout);
  相关解决方案